Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Chinese & Cantonese localization #7235

Merged
merged 14 commits into from
Dec 31, 2024
6 changes: 3 additions & 3 deletions src/components/hooks/dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ const locales: Record<AppLanguage, Locale | undefined> = {
tr,
uk,
vi,
['zh-CN']: zhCN,
['zh-HK']: zhHK,
['zh-TW']: zhTW,
['zh-Hans-CN']: zhCN,
['zh-Hant-HK']: zhHK,
['zh-Hant-TW']: zhTW,
}

/**
Expand Down
22 changes: 12 additions & 10 deletions src/locale/deviceLocales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ export function getLocales() {
}

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-Hans') ||
locale.languageTag === 'zh-CN'
) {
// Simplified Chinese to zh-Hans-CN
locale.languageTag = 'zh-Hans-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'
if (
locale.languageTag.startsWith('zh-Hant') ||
locale.languageTag === 'zh-TW'
) {
// Traditional Chinese to zh-Hant-TW
locale.languageTag = 'zh-Hant-TW'
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/locale/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
return AppLanguage.uk
case 'vi':
return AppLanguage.vi
case 'zh-CN':
case 'zh-Hans-CN':
return AppLanguage.zh_CN
case 'zh-HK':
case 'zh-Hant-HK':
return AppLanguage.zh_HK
case 'zh-TW':
case 'zh-Hant-TW':
return AppLanguage.zh_TW
default:
continue
Expand Down
6 changes: 3 additions & 3 deletions src/locale/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export enum AppLanguage {
tr = 'tr',
uk = 'uk',
vi = 'vi',
zh_CN = 'zh-CN',
zh_HK = 'zh-HK',
zh_TW = 'zh-TW',
zh_CN = 'zh-Hans-CN',
zh_HK = 'zh-Hant-HK',
zh_TW = 'zh-Hant-TW',
}

interface AppLanguageConfig {
Expand Down
Loading