Issue
I want to make my application multi language, I used two folders for them, the first one is the default values
inside the res
folder, the second one is values-ar
inside the res
folder. everything is working perfect when the language is english.
Now, i want to change it to arabic
. I used this code:
Locale locale = new Locale("ar");
Locale.setDefault(locale);
android.content.res.Configuration config = new android.content.res.Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
when i used that code, the instruction of the application like cut
and paste
are changed, but i didn't know who to tell the application to use variables from values-ar
folder, not from values
folder.
please don't worry about the encoding
thanks in advance
Solution
You can get the current language and set if condition.
String currentLang = Locale.getDefault().getDisplayLanguage();
if(currentLang == "english"){
//TODO
}else if(currentLang == "yourLang"){
//TODO
}
Hope you will find this usefull. Cheers
Answered By - MSA
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.