Reputation: 167
I am having problem in changing locale at run time in android app . I have created "values-en" and "values-mm" folders and translated the strings into respective locale. Whenever I am trying to change the locale, locale has changed but the string resources are not using "values-mm". It keep using "en" values even if I refresh the layouts. When I changed the name of "values-mm" to "values-en" , then "values-mm" resources are loaded. So I have concluded that no matter what , only "values-en" is loaded. I can't find the reason why . But the locale did changed. Any Idea what went wrong? How can I set the locale that user had chosen as the fall back locale?
Upvotes: 0
Views: 233
Reputation: 358
While updating your Local with in configurations like this you will update then the language will be changed.
public static void changeLocale(Context context, String locale) {
Resources res = context.getResources();
Configuration conf = res.getConfiguration();
conf.locale = new Locale(locale);
res.updateConfiguration(conf, res.getDisplayMetrics());
}
You can find the reference link : Using Locale to force Android to use a specific strings.xml file for a non-supported language
Upvotes: 1