Simplified and Traditional Chinese vs Regions

前端 未结 3 985
梦如初夏
梦如初夏 2020-12-02 05:50

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 t

3条回答
  •  不思量自难忘°
    2020-12-02 06:49

    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

    • zh.txt
    • zh_CN.txt
    • zh_HK.txt
    • zh_Hans.txt
    • zh_Hans_CN.txt
    • zh_Hans_HK.txt
    • zh_Hans_MO.txt
    • zh_Hans_SG.txt
    • zh_Hant.txt
    • zh_Hant_HK.txt
    • zh_Hant_MO.txt
    • zh_Hant_TW.txt
    • zh_MO.txt
    • zh_SG.txt
    • zh_TW.txt

    Hant is the ISO code for traditional and Hans for simplified chinese. So theoretically this would mean we could have

    • simplified chinese in China, HongKong, Macau and Singapore
    • traditional chinese in HongKong, Macau and Taiwan

    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.

提交回复
热议问题