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
and traditional chinese into
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?
Today, there are two different written forms of Chinese: Traditional and Simplified. Traditional Chinese preserves the orthodox characters that have been used for thousands of years. As its name suggests, Simplified Chinese consists of simplified versions of the traditional Chinese characters.
Country Spoken Language Written Language For Medicare documents and other medical forms geared toward this population it is recommended to use Traditional Chinese. Currently the majority of Chinese speakers in the U.S. use Traditional Chinese, but this trend is shifting towards Simplified Chinese.
Some people may claim that Simplified Chinese is easier to learn, but it is only partially true. Simplified Chinese characters contain fewer strokes and may be easier to remember for new learners. The actual effort involved in learning either traditional or simplified characters is quite similar.
So I think after further investigation and with Marks answer I am going to provide an answer myself. Here is goes:
Out of the box Android only has the two locales zh_rCN, which is simplified chinese and zh_rTW, which is traditional chinese. As you can see from the Settings app these are the only supplied locales:
https://android.googlesource.com/platform/packages/apps/Settings/+/master/res/
However any other creator of an Android system e.g. for a phone sold in China or so could change what they add. The overall theoretically supported set can be found by looking at the list of locales found in the icu4c app:
https://android.googlesource.com/platform/external/icu4c.git/+/master/data/locales/ As you can see for Chinese there are
Hant is the ISO code for traditional and Hans for simplified chinese. So theoretically this would mean we could have
However keep in mind that the Settings app would have to be modified to have the different selections of locale. So at this stage simplified chinese translates to zh_rCN and traditional zh_rTW and you should be apart for users that have such a modified Android image that supports other locales.
In any case to be on the save side you can use the Configuration class to get the locale e.g. in your Application class with getResources().getConfiguration().locale.
You could e.g. log that and send the data to your tracking system (whatever you use) or you could check for supported ones and throw an exception with the locale setting in the message and that would then show up in your market interface... it would however mean a minimum of one crash of your app (if you are on the ball you can publish and update a few minutes later ..)
So to recap .. the minimum setup would be mirroring what is done in the settings app (only have zh-rCN and zh-rTW), but if you want to provide for default locales for Singapore, HongKong, Macau supplying traditional chinese as default you can do that too and it should work. I have however no evidence that such a configuration is used anywhere..
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With