Coding for localization Providing alternative strings
suggest changeTo provide translations, add a strings.xml in a folder named for the locale:
res/values-<locale>/strings.xml
For example:
In this example, we have default English strings in the file res/values/strings.xml, French translations are provided in the folder res/values-fr/strings.xml and Japanese translations are provided in the folder res/values-ja/strings.xml
Other translations for other locales can similarly be added to the app.
Language folder names use ISO 639-1 codes. The alternative resources table lists them.
Non-translatable Strings:
Some strings should not be translated, such as SharedPreferences keys and symbols. Keep them only in the default strings.xml and mark them translatable="false":
<string name="pref_widget_display_label_hot">Hot News</string>
<string name="pref_widget_display_key" translatable="false">widget_display</string>
<string name="pref_widget_display_hot" translatable="false">0</string>
Translators can then skip those strings.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents