Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

rn,lang: fix language detection to take region into account

Saúl Ibarra Corretgé9be78c60ebed
diff --git a/react/features/base/i18n/languageDetector.native.js b/react/features/base/i18n/languageDetector.native.js
index 968f4c3e4a..b28e8037e3 100644
--- a/react/features/base/i18n/languageDetector.native.js
+++ b/react/features/base/i18n/languageDetector.native.js
@@ -2,6 +2,10 @@
import { NativeModules } from 'react-native';
+import LANGUAGES_RESOURCES from '../../../../lang/languages.json';
+
+const LANGUAGES = Object.keys(LANGUAGES_RESOURCES);
+
/**
* The singleton language detector for React Native which uses the system-wide
* locale.
@@ -16,8 +20,14 @@ export default {
detect() {
const { LocaleDetector } = NativeModules;
+ const [ lang, region ] = LocaleDetector.locale.replace(/_/, '-').split('-');
+ const locale = `${lang}${region}`;
+
+ if (LANGUAGES.includes(locale)) {
+ return locale;
+ }
- return LocaleDetector.locale.replace(/[_-]/, '');
+ return lang;
},
init: Function.prototype,