mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 03:12:29 +00:00
fix(i18n): Uses language-variant for translations.
This way we can take advantage of internal i18next mechanism for fallback from en-US to en and from es-ES to es and so on.
This commit is contained in:
@@ -12,13 +12,13 @@
|
||||
"en": "English",
|
||||
"eo": "Esperanto",
|
||||
"es": "Español",
|
||||
"esUS": "Español (Latinoamérica)",
|
||||
"es-US": "Español (Latinoamérica)",
|
||||
"et": "Eesti",
|
||||
"eu": "Euskara",
|
||||
"fa": "فارسی",
|
||||
"fi": "Suomi",
|
||||
"fr": "Français",
|
||||
"frCA": "Français (Canada)",
|
||||
"fr-CA": "Français (Canada)",
|
||||
"gl": "Galego",
|
||||
"he": "עברית",
|
||||
"hi": "हिन्दी",
|
||||
@@ -43,7 +43,7 @@
|
||||
"oc": "Occitan",
|
||||
"pl": "Polski",
|
||||
"pt": "Português",
|
||||
"ptBR": "Português (Brasil)",
|
||||
"pt-BR": "Português (Brasil)",
|
||||
"ro": "Română",
|
||||
"ru": "Русский",
|
||||
"sc": "Sardu",
|
||||
@@ -56,6 +56,6 @@
|
||||
"tr": "Türkçe",
|
||||
"uk": "Українська",
|
||||
"vi": "Tiếng Việt",
|
||||
"zhCN": "中文(简体)",
|
||||
"zhTW": "中文(繁體)"
|
||||
"zh-CN": "中文(简体)",
|
||||
"zh-TW": "中文(繁體)"
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ const _LANGUAGES = {
|
||||
},
|
||||
|
||||
// Spanish (Latin America)
|
||||
'esUS': {
|
||||
main: require('../../../../lang/main-esUS')
|
||||
'es-US': {
|
||||
main: require('../../../../lang/main-es-US')
|
||||
},
|
||||
|
||||
// Estonian
|
||||
@@ -66,8 +66,8 @@ const _LANGUAGES = {
|
||||
},
|
||||
|
||||
// French (Canadian)
|
||||
'frCA': {
|
||||
main: require('../../../../lang/main-frCA')
|
||||
'fr-CA': {
|
||||
main: require('../../../../lang/main-fr-CA')
|
||||
},
|
||||
|
||||
// Croatian
|
||||
@@ -116,8 +116,8 @@ const _LANGUAGES = {
|
||||
},
|
||||
|
||||
// Portuguese (Brazil)
|
||||
'ptBR': {
|
||||
main: require('../../../../lang/main-ptBR')
|
||||
'pt-BR': {
|
||||
main: require('../../../../lang/main-pt-BR')
|
||||
},
|
||||
|
||||
// Romanian
|
||||
@@ -166,13 +166,13 @@ const _LANGUAGES = {
|
||||
},
|
||||
|
||||
// Chinese (Simplified)
|
||||
'zhCN': {
|
||||
main: require('../../../../lang/main-zhCN')
|
||||
'zh-CN': {
|
||||
main: require('../../../../lang/main-zh-CN')
|
||||
},
|
||||
|
||||
// Chinese (Traditional)
|
||||
'zhTW': {
|
||||
main: require('../../../../lang/main-zhTW')
|
||||
'zh-TW': {
|
||||
main: require('../../../../lang/main-zh-TW')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
|
||||
declare let navigator: any;
|
||||
|
||||
/**
|
||||
* Custom language detection, just returns the config property if any.
|
||||
*/
|
||||
export default {
|
||||
/**
|
||||
* Does not support caching.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
cacheUserLanguage: Function.prototype,
|
||||
|
||||
/**
|
||||
* Looks the language up in the config.
|
||||
*
|
||||
* @returns {string} The default language if any.
|
||||
*/
|
||||
lookup() {
|
||||
let found = [];
|
||||
|
||||
if (typeof navigator !== 'undefined') {
|
||||
if (navigator.languages) {
|
||||
// chrome only; not an array, so can't use .push.apply instead of iterating
|
||||
for (let i = 0; i < navigator.languages.length; i++) {
|
||||
found.push(navigator.languages[i]);
|
||||
}
|
||||
}
|
||||
if (navigator.userLanguage) {
|
||||
found.push(navigator.userLanguage);
|
||||
}
|
||||
if (navigator.language) {
|
||||
found.push(navigator.language);
|
||||
}
|
||||
}
|
||||
|
||||
found = found.map<string>(normalizeLanguage);
|
||||
|
||||
return found.length > 0 ? found : undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
* Name of the language detector.
|
||||
*/
|
||||
name: 'customNavigatorDetector'
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize language format.
|
||||
*
|
||||
* (en-US => enUS)
|
||||
* (en-gb => enGB)
|
||||
* (es-es => es).
|
||||
*
|
||||
* @param {string} language - Language.
|
||||
* @returns {string} The normalized language.
|
||||
*/
|
||||
function normalizeLanguage(language: string) {
|
||||
const [ lang, variant ] = language.replace('_', '-').split('-');
|
||||
|
||||
if (!variant || lang.toUpperCase() === variant.toUpperCase()) {
|
||||
return lang;
|
||||
}
|
||||
|
||||
return lang + variant.toUpperCase();
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import BrowserLanguageDetector from 'i18next-browser-languagedetector';
|
||||
|
||||
import configLanguageDetector from './configLanguageDetector';
|
||||
import customNavigatorDetector from './customNavigatorDetector';
|
||||
|
||||
/**
|
||||
* The ordered list (by name) of language detectors to be utilized as backends
|
||||
@@ -16,7 +15,7 @@ const order = [
|
||||
|
||||
// Allow i18next to detect the system language reported by the Web browser
|
||||
// itself.
|
||||
interfaceConfig.LANG_DETECTION && order.push(customNavigatorDetector.name);
|
||||
interfaceConfig.LANG_DETECTION && order.push('navigator');
|
||||
|
||||
// Default use configured language
|
||||
order.push(configLanguageDetector.name);
|
||||
@@ -34,11 +33,6 @@ const languageDetector
|
||||
order
|
||||
});
|
||||
|
||||
// Add the language detector which looks the language up in the config. Its
|
||||
// order has already been established above.
|
||||
// @ts-ignore
|
||||
languageDetector.addDetector(customNavigatorDetector);
|
||||
|
||||
// @ts-ignore
|
||||
languageDetector.addDetector(configLanguageDetector);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user