diff options
author | Frudrax Cheng <i@cynosura.one> | 2024-11-22 19:32:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-22 11:32:25 +0000 |
commit | 09ce65b24e968cfc0c45d8239dfbc995afcc78a8 (patch) | |
tree | 8fe06b399803444cef5df668eaec5d59765e22bd /src/locale/deviceLocales.ts | |
parent | c858700c173340c912e0aa4b8d0f921218a8df6e (diff) | |
download | voidsky-09ce65b24e968cfc0c45d8239dfbc995afcc78a8.tar.zst |
Fix display language not switching correctly to Chinese on native. (#6621)
* Update deviceLocales.ts * Update deviceLocales.ts
Diffstat (limited to 'src/locale/deviceLocales.ts')
-rw-r--r-- | src/locale/deviceLocales.ts | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/locale/deviceLocales.ts b/src/locale/deviceLocales.ts index 9e19e372b..1abaa20f6 100644 --- a/src/locale/deviceLocales.ts +++ b/src/locale/deviceLocales.ts @@ -13,6 +13,12 @@ type LocalWithLanguageCode = Locale & { * * {@link https://github.com/bluesky-social/social-app/pull/4461} * {@link https://xml.coverpages.org/iso639a.html} + * + * Convert Chinese language tags for Native. + * + * {@link https://datatracker.ietf.org/doc/html/rfc5646#appendix-A} + * {@link https://developer.apple.com/documentation/packagedescription/languagetag} + * {@link https://gist.github.com/amake/0ac7724681ac1c178c6f95a5b09f03ce#new-locales-vs-old-locales-chinese} */ export function getLocales() { const locales = defaultGetLocales?.() ?? [] @@ -32,10 +38,25 @@ export function getLocales() { // yiddish locale.languageCode = 'yi' } + } - // @ts-ignore checked above - output.push(locale) + if (typeof locale.languageTag === 'string') { + if (locale.languageTag.startsWith('zh-Hans')) { + // Simplified Chinese to zh-CN + locale.languageTag = 'zh-CN' + } + if (locale.languageTag.startsWith('zh-Hant')) { + // Traditional Chinese to zh-TW + locale.languageTag = 'zh-TW' + } + if (locale.languageTag.startsWith('yue')) { + // Cantonese (Yue) to zh-HK + locale.languageTag = 'zh-HK' + } } + + // @ts-ignore checked above + output.push(locale) } return output |