Most of the localization application provides alternative text for different languages. In some cases, you also have alternative graphics, sounds, layouts, and other local resources.
An application can specify many res // directories, each with different qualifiers. To create an alternative resource for another language, you use a qualifier that indicates the language or language area. (The name of the resource directory must match the naming scheme described in Providing alternative resources or it will not compile otherwise.)
Example:
Suppose your default language application is English. also assume that you want to localize all the text in your application in French, and most of the text in your application (everything except the name of the application) in Japanese. In this case, you can create three alternative strings.xml files, each stored in a local Directory resource:
- RES / values / strings.xml Contains English text for all lines that the application uses, including text for a line with the name name.
- RES / value-pt / strings.xml Contain French text for all lines, including the heading.
- RES / values-JA / strings.xml Contains Japanese text for all lines except the name.
If your Java code refers to R.string.title, here is what will happen at runtime:
* If the device is set to any language other than French, Android
will load the header from res / values /strings.xml. * If the device is set to French, Android will download the header from res / values-fr / strings.xml.
Please note that if the device is installed in Japanese, Android will look for the name in the res / values-ja / strings.xml file. But since such a line is not included in this Android file will disappear by default, and load the title in English from res / values /strings.xml.
To change the localization of your application, you can use the following code snippet: