Chinese Locale in Android (Part 1)

Fabio Lee
FabioHub
Published in
1 min readDec 31, 2016

When we talk about Chinese language globally, there are three major categories:

  • Simplified Chinese
  • Traditional Chinese
  • Chinese

Where Android is using Locale.SIMPLIFIED_CHINESE (Before Android 7.0: zh-rCN; After Android 7.0: zh-rCN_#Hans), Locale.TRADITIONAL_CHINESE (Before Android 7.0: zh-rTW; After Android 7.0: zh-rTW_#Hant) & Locale.CHINESE (Before & After Android 7.0: zh) to represent them.

Here come the problem, when a Hong Kong device which prefer to view in Traditional Chinese, which strings.xml resource will the Android mobile app use?

Before Android 7.0, Android could not always successfully match app and system locales.

User Settings

  • zh-rHK

App Resources

  • default (en)
  • zh-rCN
  • zh-rTW
  • zh

Resource Resolution

  1. Try zh-rHK => Fail
  2. Try zh => Success
  3. Use zh

Starting in Android 7.0, Android is changing the way the system resolves resources.

User Settings

  • zh-rHK_#Hant

App Resources

  • default (en)
  • zh-rCN_#Hans
  • zh-rTW_#Hant
  • zh

Resource Resolution

  1. Try zh-rHK_#Hant => Fail
  2. Try zh-r_#Hant => Fail
  3. Try children of zh-r_#Hant => zh-rTW_#Hant
  4. Use zh-rTW#Hant

In order to support both before & after Android 7.0 devices, I believe the minimum resources needed to maintain will be:

  • en (English)
  • zh-rCN (Simplified Chinese)
  • zh-rTW (Traditional Chinese)
  • zh (Traditional Chinese)

--

--