Essential Android Internalization and localization edit forum

Coding for localization Providing alternative strings

To provide translations in other languages (locales), we need to create a strings.xml in a separate folder by the following convention :


An example for the same is given below:

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.

A complete list of locale codes can be found here : ISO 639 codes

Non-translatable Strings:

Your project may have certain strings that are not to be translated. Strings which are used as keys for SharedPreferences or strings which are used as symbols, fall in this category. These strings should be stored only in the default strings.xml and should be marked with a translatable="false" attribute. e.g.

<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>

This attribute is important because translations are often carried out by professionals who are bilingual. This would allow these persons involved in translations to identify strings which are not to be translated, thus saving time and money.

Table Of Contents
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
205 Internalization and localization
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close