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

Add Cantonese Localization #5479

Merged
merged 15 commits into from
Oct 7, 2024
Merged
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',},
auroursa marked this conversation as resolved.
Show resolved Hide resolved
{code2: AppLanguage.zh_TW, name: '繁體中文 – Traditional Chinese'},
{code2: AppLanguage.zh_HK, name: '粵文 – Cantonese'},
]

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