How to create alternative resources?
A large part of localizing an app is providing alternative text for different languages. In some cases you also provide alternative graphics, sounds, layouts, and other locale-specific resources.
An app can specify many res/<qualifiers>/ directories, each with different qualifiers. To create an alternative resource for a different locale, you use a qualifier that specifies a language or a language-region combination. (The name of a resource directory must conform to the naming scheme described in Providing Alternative Resources, or else your app cannot compile.)
Example:
Suppose that your app's default language is English. Suppose also that you want to localize all the text in your app to French, and most of the text in your app (everything except the app's title) to Japanese. In this case, you could create three alternative strings.xml files, each stored in a locale-specific resource directory:
1.
res/values/strings.xml
Contains English text for all the strings that the app uses, including text for
a string named title.
2.
res/values-fr/strings.xml
Contain French text for all the strings, including title.
3.
res/values-ja/strings.xml
Contain Japanese text for all the strings except title.
If your Java-based code refers to R.string.title, here is what happens at runtime:
Ø If the device is set to any language other than French, Android loads title from the res/values/strings.xmlfile.
Ø If the device is set to French, Android loads title from the res/values-fr/strings.xml file.
Notice that if the device is set to Japanese, Android looks for title in the res/values-ja/strings.xml file. But because no such string is included in that file, Android falls back to the default, and loads title in English from theres/values/strings.xml file.