0

I have an App with multiple languages (fr, it, en, pt, es) and I would like to dinamically choose which to use at runtime.

Example:

I'm from US but I choose to "discover" Italy. I'd like my app to use string.xml from resource "it" even if my default language from phone is "en".

I do not want to modify the file string.xml at runtime, I want to use another string.xml, different from my default choosen by the Android. Of course, my phone should remain in EN - I just want to change for my app at that certain point.

1 Answers1

0

You can set the Locale for your app with something like this, maybe on the onCreate method of your Activity:

Configuration configuration = resources.getConfiguration();
Locale esLocale = new Locale("es", "ES"); //Spanish
Locale.setDefault(locale);
configuration.locale = locale;
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
s1m3n
  • 623
  • 6
  • 21