Browse Source

Replaced expo localization by react native one

Arnaud Vergnet 1 year ago
parent
commit
b784a5d164
2 changed files with 5 additions and 4 deletions
  1. 1
    1
      package.json
  2. 4
    3
      src/managers/LocaleManager.js

+ 1
- 1
package.json View File

@@ -27,7 +27,6 @@
27 27
     "expo": "^37.0.0",
28 28
     "expo-barcode-scanner": "~8.1.0",
29 29
     "expo-camera": "latest",
30
-    "expo-localization": "~8.1.0",
31 30
     "expo-permissions": "~8.1.0",
32 31
     "expo-secure-store": "~8.1.0",
33 32
     "i18n-js": "^3.3.0",
@@ -43,6 +42,7 @@
43 42
     "react-native-gesture-handler": "~1.6.0",
44 43
     "react-native-image-modal": "^1.0.6",
45 44
     "react-native-linear-gradient": "^2.5.6",
45
+    "react-native-localize": "^1.4.0",
46 46
     "react-native-modalize": "^1.3.6",
47 47
     "react-native-paper": "^3.8.0",
48 48
     "react-native-reanimated": "~1.7.0",

+ 4
- 3
src/managers/LocaleManager.js View File

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import i18n from 'i18n-js';
4
-import * as Localization from 'expo-localization';
4
+import * as RNLocalize from "react-native-localize";
5 5
 
6 6
 import en from '../../translations/en';
7 7
 import fr from '../../translations/fr';
@@ -17,10 +17,11 @@ export default class LocaleManager {
17 17
     static initTranslations() {
18 18
         i18n.fallbacks = true;
19 19
         i18n.translations = {fr, en};
20
-        i18n.locale = Localization.locale;
20
+        i18n.locale = RNLocalize.findBestAvailableLanguage(["en", "fr"]).languageTag;
21
+        console.log(RNLocalize.findBestAvailableLanguage(["en", "fr"]).languageTag);
21 22
     }
22 23
 
23 24
     static getCurrentLocale() {
24
-        return Localization.locale;
25
+        return RNLocalize.findBestAvailableLanguage(["en", "fr"]).languageTag;
25 26
     }
26 27
 }

Loading…
Cancel
Save