'Simplified and Traditional Chinese vs Regions

In the process of implementing traditional and simplified chinese support in my Android application and I confused on how this is supposed to work.

So from reading the documentation as well as some discussions like this and this I have put simplified chinese into

  • values-zh
  • values-zh-rCN
  • values-zh-rSG

and traditional chinese into

  • values-zh-rTW
  • values-zh-rHK

That all works fine but somehow does not make sense to me (sorry if I dont understand enough about chinese simplified vs traditional usage).

From what I understand from checking the locale setting dialog in the emulator as well as on a rooted phone a user can change the locale to Simplified Chinese or Traditional Chinese.

Now here is the question. How does the system know where to get the simplified or traditional chinese strings.xml. Is there some sort of assumption baked in that says if I am supposed to display simplified chinese get it from values-zh and get traditional from values-zh-rTW?

But what if a user is located in HK and set his device up to display simplified chinese? Or what if an emigrant somewhere else in the world sets his device to traditional chinese but his region is e.g. US or CA?

What do I have to do to allow my users to set their locale and have my app appear with the right locale?

Update:

From further investigation I believe that a Android phone user can not set the country separately from the language. They can only set what is called the locale in the UI. It consists of language and country, but the list is limited so many combinations are not possible.

E.g. a Chinese person living in the US that wants to use Traditional Chinese could set the language to traditional chinese (at least on a rooted phone) and would then have a locale of zh-rTW. He could in no way set his country separately to be US. In a similar manner any sort of emigrant can not set their native language with the country they currently live in..

Basically that means that only a bunch of combinations of language and country are supported. Now the questions is how to find out which ones they are?



Solution 1:[1]

Updated answer

The question and previous answers are pretty old. It is hard to tell how correct they still are. This answer is for other people coming here who just want to support both Traditional and Simplified Chinese in their app, but are not overly concerned about the details of locality.

Add string.xml files for Traditional and Simplified Chinese

In Android Studio right click the res folder and choose New > Android resource file. Type in strings for the File name and choose Locale from the list.

enter image description here

Scroll down to zh for the language. Add one strings file for CN: China (simplified) and one for TW: Taiwan (traditional). If you are only using one then just choose Any Region.

As I understand the documentation, lookup will first check if there is an exact match for language and region (Example: Chinese-Traditional-Taiwan). Then it will fall back to broader checks. (This system is as of Android 7.0.)

1. zh-Hant-TW   // Chinese - Traditional - Taiwan
2. zh-Hant      // Chinese - Traditional
3. zh           // Chinese

I'm not completely sure about how all this works so please read this and this documentation.

Following this method in my own app, switching the system settings between Traditional and Simplified changed the app display also.

Converting between Traditional and Simplified

If you already have one translation in either Traditional or Simplified, you can auto convert the text online. Start with Google Translate to convert to the other (just paste in your strings.xml file). It does a fairly good job already. Then do it again several times using one of the many online converters. Use a text comparing tool or site (text-compare.com is good) to compare the result of the conversions. That will help you catch any mistakes that Google made.

Solution 2:[2]

https://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

Android 7.0 (API level 24) introduced support for BCP 47 language tags, which you can use to qualify language- and region-specific resources. A language tag is composed from a sequence of one or more subtags, each of which refines or narrows the range of language identified by the overall tag.

you can now define traditional or simplified using the BCP 47 tags. (To use a BCP 47 language tag, concatenate b+ and a two-letter ISO 639-1 language code, optionally followed by additional subtags separated by +.)

more specifically: -

Simplified:

values-b+zh (defaults to simplified) 
values-b+zh+Hans or
values-b+zh+Hans+CN (if you want to include regions)

Traditional:

values-b+zh+Hant or
values-b+zh+TW (defaults to traditional)
values-b+zh+Hant+TW (if you want to include regions)

you can look at https://tools.ietf.org/html/bcp47 for other interesting combinations. including: -

  zh-cmn-Hans-CN (Chinese, Mandarin, Simplified script, as used in
  China)

  cmn-Hans-CN (Mandarin Chinese, Simplified script, as used in
  China)

  zh-yue-HK (Chinese, Cantonese, as used in Hong Kong SAR)

  yue-HK (Cantonese Chinese, as used in Hong Kong SAR)

  zh-nan-TW (min nan Chinese, as used in Taiwan)

  zh-hak-CN (Chinese, Hakka, China).

remember to add -b and replace the - in each tag with +

Solution 3:[3]

I have created this table, hope it helps someone.

CODE LANG FORM REGION
zh Chinese - -
zh_Hans Chinese Han Simplified -
zh_Hans_CN Chinese Han Simplified China
zh_Hans_HK Chinese Han Simplified Hong Kong SAR China
zh_Hans_MO Chinese Han Simplified Macau SAR China
zh_Hans_SG Chinese Han Simplified Singapore
zh_Hant Chinese Han Traditional -
zh_Hant_HK Chinese Han Traditional Hong Kong SAR China
zh_Hant_MO Chinese Han Traditional Macau SAR China
zh_Hant_TW Chinese Han Traditional Taiwan

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 Angel Koh
Solution 3 Kerem BaydoÄŸan