Localized new ui to zh-TW (#5942)
* Create zh-TW.json * Update _sync-report.json * Update languages.ts * Update config.ts * fix(i18n): update language codes and improve translations for zh-CN and zh-TW
This commit is contained in:
+1
-1
@@ -39,7 +39,7 @@ export function LanguageSwitcher() {
|
||||
const { i18n, t } = useTranslation()
|
||||
const user = useAuthStore((s) => s.auth.user)
|
||||
const currentLanguage = normalizeInterfaceLanguage(i18n.language)
|
||||
|
||||
console.log('Current interface language: %s', currentLanguage)
|
||||
const handleChangeLanguage = useCallback(
|
||||
async (code: string) => {
|
||||
await i18n.changeLanguage(code)
|
||||
|
||||
Vendored
+6
-4
@@ -25,15 +25,17 @@ import fr from './locales/fr.json'
|
||||
import ja from './locales/ja.json'
|
||||
import ru from './locales/ru.json'
|
||||
import vi from './locales/vi.json'
|
||||
import zh from './locales/zh.json'
|
||||
import zhCN from './locales/zh.json'
|
||||
import zhTW from './locales/zh-TW.json'
|
||||
|
||||
export const resources = {
|
||||
en,
|
||||
zh,
|
||||
zhCN,
|
||||
fr,
|
||||
ru,
|
||||
ja,
|
||||
vi,
|
||||
zhTW
|
||||
} as const
|
||||
|
||||
i18n
|
||||
@@ -42,8 +44,8 @@ i18n
|
||||
.init({
|
||||
resources,
|
||||
fallbackLng: 'en',
|
||||
supportedLngs: ['en', 'zh', 'fr', 'ru', 'ja', 'vi'],
|
||||
load: 'languageOnly', // Convert zh-CN -> zh
|
||||
supportedLngs: ['en', 'zhCN', 'fr', 'ru', 'ja', 'vi','zhTW'],
|
||||
load: 'currentOnly', // Convert zh-CN -> zh
|
||||
nsSeparator: false, // Allow literal colons in keys (e.g., URLs, labels)
|
||||
debug: import.meta.env.DEV,
|
||||
interpolation: {
|
||||
|
||||
Vendored
+10
-3
@@ -18,12 +18,13 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
export const INTERFACE_LANGUAGE_OPTIONS = [
|
||||
{ code: 'zh', label: '简体中文' },
|
||||
{ code: 'zhCN', label: '简体中文' },
|
||||
{ code: 'en', label: 'English' },
|
||||
{ code: 'fr', label: 'Français' },
|
||||
{ code: 'ru', label: 'Русский' },
|
||||
{ code: 'ja', label: '日本語' },
|
||||
{ code: 'vi', label: 'Tiếng Việt' },
|
||||
{ code: 'zhTW', label: '繁體中文' }
|
||||
] as const
|
||||
|
||||
export type InterfaceLanguageCode =
|
||||
@@ -32,9 +33,15 @@ export type InterfaceLanguageCode =
|
||||
export function normalizeInterfaceLanguage(value?: string | null): string {
|
||||
if (!value) return 'en'
|
||||
|
||||
const normalized = value.trim().replace(/_/g, '-').toLowerCase()
|
||||
if (normalized.startsWith('zh')) return 'zh'
|
||||
var normalized = value.trim().replace(/_/g, '-').toLowerCase()
|
||||
if (value === 'zh-TW' || value === 'zh-HK' || value === 'zh-MO' || value === 'zhTW') {
|
||||
normalized = 'zhTW'
|
||||
}
|
||||
if (value === 'zh-CN' || value === 'zh-Hans' || value === "zhCN") {
|
||||
normalized = 'zhCN'
|
||||
}
|
||||
|
||||
console.log('Normalized interface language: %s -> %s', value, normalized)
|
||||
return INTERFACE_LANGUAGE_OPTIONS.some((lang) => lang.code === normalized)
|
||||
? normalized
|
||||
: 'en'
|
||||
|
||||
@@ -36,6 +36,12 @@
|
||||
"missingCount": 0,
|
||||
"extrasCount": 0,
|
||||
"untranslatedCount": 0
|
||||
},
|
||||
"zh-TW": {
|
||||
"file": "zh-TW.json",
|
||||
"missingCount": 0,
|
||||
"extrasCount": 0,
|
||||
"untranslatedCount": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5062
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user