Apple uses non-canonical ISO 639 code for Chinese localization in iOS/MacOS

100 Views Asked by At

I have written an App which internally supports a number of different languages in its UI/Strings without changing device region. All was working fine except Chinese. Apple dox state they use ISO 639-1 or -2 codes. https://developer.apple.com/documentation/foundation/nslocale/1418015-isolanguagecodes

The ISO language code table says the code for Chinese(Simplified) is "zh" or "zh-TW" (Taiwan)

https://www.loc.gov/standards/iso639-2/php/English_list.php

My app uses several language processing APIs which use the standard ISO codes.

Using Xcode 14.01, and digging into the App Bundle, I found it creates lproj files with names of zh-Hans and zh-Hant when you add Chinese localization instead of zh and zh-TW. All other language localizations I checked conform to ISO. It took a few hours of digging to find this issue, so I thought I would mention this boobytrap to other developers.

My question: Why doesn't Apple use ISO consistently, or at least update their documentation?

1

There are 1 best solutions below

0
BlueskyMed On

You must end up special casing Chinese, using zh-Hans or zh-Hant in your App, but zh or zh-TW in other APIs. All other language in Apple localization use standard ISO 639 codes.