Automatic locale selection, according to user settings
The strings.xml
contains the original text, assuming for the English language.
To create translations into different languages you can create folders, for example:
values-gr
, values.it
, for the Greek end Italian.
Just copy strings.xml
into those folders and translate it.
On application launch, OS automatically picks a language according to the user's preferences.
Manually locale selection, overriding user settings
To force Greek for example you can use:
Locale locale = new Locale("gr");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
You should, of course, provide a Greek translation for this to work.
Read more
You can check the documentation here: Support Different Languages - Android