支持马拉地语 [英] Support for marathi language
问题描述
我所有的文本都放在string.xml
文件中,这些文件又包含在文件夹values- values-en
中.如何指定Locale marathi或让我知道values文件夹的语言说明符以获取marathi字符串
All my texts are in string.xml
files which in turn contained in the folders values- values-en
. how to specify Locale marathi or please let me know the language specifier for values folder to fetch marathi strings
public void setLanguage(String language) {
Locale locale = new Locale(language);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
Locale.getAvailableLocales();
if (checkForLocaleSupport(locale)) {
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
}
}
public boolean checkLocaleSupport(Locale locale){
Locale[] locs= Locale.getAvailableLocales();
for(Locale l:locs){
if(l.equals(locale)){
return true;
}
}
return false;
}
在我主要活动的oncreate()方法中,在设置内容之前将语言设置为setLanguage("hi").然后设置内容并在执行mHeaderText.setText(R.string.my_header)时引入textview我的头文件是从values-hi文件夹中的string.xml中读取的.但是,如果我将语言设置为"mr",则不会从values-mr文件夹中提取字符串.非常感谢您的帮助
In oncreate() method of my main activity im setting language as setLanguage("hi") before setting the content. then after setting the content and intilisizing a textview im doing mHeaderText.setText(R.string.my_header); my header is read from string.xml in values-hi folder. but if I set language as "mr" , string is not fetched from values-mr folder. Greatly appreciate the help
推荐答案
因此,根据我在注释中给您的2个链接,应该将其作为文件夹的values-mr
.
So it shoudl be values-mr
for your folder from the 2 links I gave you in comments.
相关链接: http://developer.android.com/reference/java/util/Locale.html
http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
这篇关于支持马拉地语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!