fix(i18n): Fix Chinese language issues and hyphenated locale persistence

- Fix missing Chinese translations in main-zh-CN.json and main-zh-TW.json
- Fix language selection not persisting for hyphenated locales (zh-CN, zh-TW, es-US, fr-CA, pt-BR)
- Update normalizeCurrentLanguage to check exact match before normalization
This commit is contained in:
Kerinlin
2025-10-23 11:19:23 +08:00
committed by Дамян Минков
parent 6784921429
commit bf23107e7a
4 changed files with 138 additions and 3 deletions

View File

@@ -80,7 +80,7 @@ const options: i18next.InitOptions = {
interpolation: {
escapeValue: false // not needed for react as it escapes by default
},
load: 'languageOnly',
load: 'all',
ns: [ 'main', 'languages', 'countries', 'translation-languages' ],
react: {
// re-render when a new resource bundle is added

View File

@@ -96,6 +96,11 @@ function normalizeCurrentLanguage(language: string) {
return;
}
// First check if the language code exists as-is (e.g., 'zh-CN', 'fr-CA')
if (LANGUAGES.includes(language)) {
return language;
}
const [ country, lang ] = language.split('-');
const jitsiNormalized = `${country}${lang ?? ''}`;