Browse Source

Replaced expo localization by react native one

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

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

1
 // @flow
1
 // @flow
2
 
2
 
3
 import i18n from 'i18n-js';
3
 import i18n from 'i18n-js';
4
-import * as Localization from 'expo-localization';
4
+import * as RNLocalize from "react-native-localize";
5
 
5
 
6
 import en from '../../translations/en';
6
 import en from '../../translations/en';
7
 import fr from '../../translations/fr';
7
 import fr from '../../translations/fr';
17
     static initTranslations() {
17
     static initTranslations() {
18
         i18n.fallbacks = true;
18
         i18n.fallbacks = true;
19
         i18n.translations = {fr, en};
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
     static getCurrentLocale() {
24
     static getCurrentLocale() {
24
-        return Localization.locale;
25
+        return RNLocalize.findBestAvailableLanguage(["en", "fr"]).languageTag;
25
     }
26
     }
26
 }
27
 }

Loading…
Cancel
Save