Configure your project
First, you need to add the following configuration in your file build.gradle (Module : app) :
android {
.....
androidResources {
generateLocaleConfig = true
}
}
In the "res" directory, define the default language. To do that, you need to create resources.properties file with the following content :
unqualifiedResLocale=en-US
You will probably need to resynchronize your project.
Define strings.xml for each country
You could create the string.xml file which will contains the translation
for the country you choose. For example, il you want to translate in Japanese,
create the strings.xml for Japanese :
Define and use translation
Example:
<resources>
<string name="advanced">Advanced</string>
Then, in French strings.xml, you set the translation :
<resources><string name="advanced">Avancé</string>
Other way to use locale in your code
If your phone is in Japanese, then this will use the corresponding strings.xml file
In my small Android application QuizzBee, I load files according to language :