Skip to content

Commit

Permalink
Update Chinese & Cantonese localization (#7235)
Browse files Browse the repository at this point in the history
* Update translates from crowdin

* Convert language codes from RFC-1766 to RFC-4646

* Update translates from crowdin

* Update deviceLocales.ts

* Revert 'changes zh-HK to yue'

* Fix zh-HK messages.po

* Revert 'en/messages.po'

* Update deviceLocales.ts

* Revert code comments

* Update translates from crowdin

* zh-TW: Improved translations
  • Loading branch information
auroursa authored Dec 31, 2024
1 parent 444c4a9 commit cf1ccdf
Show file tree
Hide file tree
Showing 7 changed files with 575 additions and 608 deletions.
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

0 comments on commit cf1ccdf

Please sign in to comment.