Skip to content

Commit

Permalink
Add Cantonese Localization (#5479)
Browse files Browse the repository at this point in the history
* Add zh-HK localization

* Update dates.ts

* HK: Update Translates

* HK: Fix typo

* HK: Fix wrong language code

* HK: Update Translates

* HK: Update Translates

* rename 'Chinese (Hong Kong)' to 'Cantonese'

* HK: Update Translates

* Update languages.ts

Co-authored-by: surfdude29 <[email protected]>

* HK: Update Translates by reviewers

---------

Co-authored-by: surfdude29 <[email protected]>
  • Loading branch information
auroursa and surfdude29 authored Oct 7, 2024
1 parent ff70b8f commit d28186a
Show file tree
Hide file tree
Showing 7 changed files with 7,877 additions and 2 deletions.
1 change: 1 addition & 0 deletions lingui.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
'tr',
'uk',
'zh-CN',
'zh-HK',
'zh-TW',
],
catalogs: [
Expand Down
2 changes: 2 additions & 0 deletions src/components/hooks/dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
tr,
uk,
zhCN,
zhHK,
zhTW,
} from 'date-fns/locale'

Expand Down Expand Up @@ -52,6 +53,7 @@ const locales: Record<AppLanguage, Locale | undefined> = {
tr,
uk,
['zh-CN']: zhCN,
['zh-HK']: zhHK,
['zh-TW']: zhTW,
}

Expand Down
2 changes: 2 additions & 0 deletions src/locale/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export function sanitizeAppLanguageSetting(appLanguage: string): AppLanguage {
return AppLanguage.uk
case 'zh-CN':
return AppLanguage.zh_CN
case 'zh-HK':
return AppLanguage.zh_HK
case 'zh-TW':
return AppLanguage.zh_TW
default:
Expand Down
9 changes: 9 additions & 0 deletions src/locale/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {messages as messagesRu} from '#/locale/locales/ru/messages'
import {messages as messagesTr} from '#/locale/locales/tr/messages'
import {messages as messagesUk} from '#/locale/locales/uk/messages'
import {messages as messagesZh_CN} from '#/locale/locales/zh-CN/messages'
import {messages as messagesZh_HK} from '#/locale/locales/zh-HK/messages'
import {messages as messagesZh_TW} from '#/locale/locales/zh-TW/messages'
import {useLanguagePrefs} from '#/state/preferences'

Expand Down Expand Up @@ -164,6 +165,14 @@ export async function dynamicActivate(locale: AppLanguage) {
])
break
}
case AppLanguage.zh_HK: {
i18n.loadAndActivate({locale, messages: messagesZh_HK})
await Promise.all([
import('@formatjs/intl-pluralrules/locale-data/zh'),
import('@formatjs/intl-numberformat/locale-data/zh'),
])
break
}
case AppLanguage.zh_TW: {
i18n.loadAndActivate({locale, messages: messagesZh_TW})
await Promise.all([
Expand Down
4 changes: 4 additions & 0 deletions src/locale/i18n.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export async function dynamicActivate(locale: AppLanguage) {
mod = await import(`./locales/zh-CN/messages`)
break
}
case AppLanguage.zh_HK: {
mod = await import(`./locales/zh-HK/messages`)
break
}
case AppLanguage.zh_TW: {
mod = await import(`./locales/zh-TW/messages`)
break
Expand Down
6 changes: 4 additions & 2 deletions src/locale/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum AppLanguage {
tr = 'tr',
uk = 'uk',
zh_CN = 'zh-CN',
zh_HK = 'zh-HK',
zh_TW = 'zh-TW',
}

Expand All @@ -47,8 +48,9 @@ export const APP_LANGUAGES: AppLanguageConfig[] = [
{code2: AppLanguage.ru, name: 'Русский – Russian'},
{code2: AppLanguage.tr, name: 'Türkçe – Turkish'},
{code2: AppLanguage.uk, name: 'Українська – Ukrainian'},
{code2: AppLanguage.zh_CN, name: '简体中文(中国)– Chinese (Simplified)'},
{code2: AppLanguage.zh_TW, name: '繁體中文(臺灣)– Chinese (Traditional)'},
{code2: AppLanguage.zh_CN, name: '简体中文 – Simplified Chinese'},
{code2: AppLanguage.zh_TW, name: '繁體中文 – Traditional Chinese'},
{code2: AppLanguage.zh_HK, name: '粵文 – Cantonese'},
]

export const LANGUAGES: Language[] = [
Expand Down
Loading

0 comments on commit d28186a

Please sign in to comment.