Android – Localization

In Android application development, there is a strings.xml which centralizes all the text values of the application. In order to localize your application by the phone locale, we can simply create different strings.xml as depicted in the following picture.

Localization mapping:
1. If the phone locale is NOT with language code zh, then
    – /values/strings.xml will be shown

2. If the phone locale is with language code zh but DOES NOT belong to CN/TW region, then
    – /values-zh/strings.xml will be shown

3. If the phone locale is zh-TW, then
    – /values-zh-rTW/strings.xml will be shown

4. If the phone locale is zh-CN, then
    – /values-zh-rCN/strings.xml will be shown

Please note that you only nehttps://ykyuen.wordpress.com/wp-admin/post.php?action=edit&post=843ed to copy the text values which u want to localize to those /values-XX/strings.xml. If the string is not found, then it will show the value in the default strings.xml inside the /values folder.

In addition, localization of /drawable and /layout can be done by creating the corresponding folders such as /drawable-zh-rTW and /layout-zh-rTW.

Done =)

Reference: Android Developers Google Group – Localizing Android Apps

2 thoughts on “Android – Localization”

  1. Thanks for this useful information! I have two questions:

    Are there a lot of people with language code zh but who do NOT belong to CN/TW region?

    My app has been translated to zh-rCN and zh-rTW, but not zh.
    Is it a good idea to duplicate zh-rCN to zh?

    Like

    1. Hi Nicolas,

      For question 1. i think you can also add zh-rHK for Hong Kong users. They also use traditional chinese character which is the same as Taiwan.

      For question 2. i think it would be no harm to duplicate zh-rCN to zh although i guess not many users are in this range. so go ahead

      hope this help =)

      Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.