I\'m working on an application that has localized strings for the UK, specified in res/values-en-rGB/strings.xml
. My default string implementations, for the US,
Should happen automatically, without you doing anything. If you have values/strings.xml
, values-en-rGB/strings.xml
and values-en-rCA/strings.xml
with the GB and CA versions containing only those strings that differ from the baseline (values/strings.xml
) and if the user has his locale as en-CA, the system will load strings from values-en-rCA/strings.xml
if not found, it'll fall back to values/strings.xml
, the GB version wouldn't come in the picture.
For this you'll have to locally change your app locale. Basically you get the current locale, if it is fr-CA, you manually set the locale to en-CA
Locale enCALocale = new Locale("en", "CA");
Locale.setDefault(enCALocale);
Configuration config = new Configuration();
config.locale = enCALocale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
Update
As Shobhit mentioned, starting Android N, you can now have a list of locales selected in the setting and you can decide their priority:
In the above case the system will try and look for en-rCA/strings
, if not found it'll look into en-rGB/strings
instead of baseline, something that happened before N.