Selaa lähdekoodia

fix(i18n): LocaleDetector should consider the language tag

master
lala 4 vuotta sitten
vanhempi
commit
35c7f156db

+ 2
- 2
android/sdk/src/main/java/org/jitsi/meet/sdk/LocaleDetector.java Näytä tiedosto

@@ -47,7 +47,7 @@ class LocaleDetector extends ReactContextBaseJavaModule {
47 47
     public Map<String, Object> getConstants() {
48 48
         Context context = getReactApplicationContext();
49 49
         HashMap<String,Object> constants = new HashMap<>();
50
-        constants.put("locale", context.getResources().getConfiguration().locale.toString());
50
+        constants.put("locale", context.getResources().getConfiguration().locale.toLanguageTag());
51 51
         return constants;
52 52
     }
53 53
 
@@ -55,4 +55,4 @@ class LocaleDetector extends ReactContextBaseJavaModule {
55 55
     public String getName() {
56 56
         return "LocaleDetector";
57 57
     }
58
-}
58
+}

+ 11
- 2
react/features/base/i18n/languageDetector.native.js Näytä tiedosto

@@ -20,8 +20,17 @@ export default {
20 20
 
21 21
     detect() {
22 22
         const { LocaleDetector } = NativeModules;
23
-        const [ lang, region ] = LocaleDetector.locale.replace(/_/, '-').split('-');
24
-        const locale = `${lang}${region}`;
23
+        const parts = LocaleDetector.locale.replace(/_/, '-').split('-');
24
+        const [ lang, regionOrScript, region ] = parts;
25
+        let locale;
26
+
27
+        if (parts.length >= 3) {
28
+            locale = `${lang}${region}`;
29
+        } else if (parts.length === 2) {
30
+            locale = `${lang}${regionOrScript}`;
31
+        } else {
32
+            locale = lang;
33
+        }
25 34
 
26 35
         if (LANGUAGES.includes(locale)) {
27 36
             return locale;

Loading…
Peruuta
Tallenna