From b784a5d1649467ef3944d4f3bc204f553202c4b9 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Mon, 27 Apr 2020 21:47:49 +0200 Subject: [PATCH] Replaced expo localization by react native one --- package.json | 2 +- src/managers/LocaleManager.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a7e1f07..021965a 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "expo": "^37.0.0", "expo-barcode-scanner": "~8.1.0", "expo-camera": "latest", - "expo-localization": "~8.1.0", "expo-permissions": "~8.1.0", "expo-secure-store": "~8.1.0", "i18n-js": "^3.3.0", @@ -43,6 +42,7 @@ "react-native-gesture-handler": "~1.6.0", "react-native-image-modal": "^1.0.6", "react-native-linear-gradient": "^2.5.6", + "react-native-localize": "^1.4.0", "react-native-modalize": "^1.3.6", "react-native-paper": "^3.8.0", "react-native-reanimated": "~1.7.0", diff --git a/src/managers/LocaleManager.js b/src/managers/LocaleManager.js index 15c5390..7f916d8 100644 --- a/src/managers/LocaleManager.js +++ b/src/managers/LocaleManager.js @@ -1,7 +1,7 @@ // @flow import i18n from 'i18n-js'; -import * as Localization from 'expo-localization'; +import * as RNLocalize from "react-native-localize"; import en from '../../translations/en'; import fr from '../../translations/fr'; @@ -17,10 +17,11 @@ export default class LocaleManager { static initTranslations() { i18n.fallbacks = true; i18n.translations = {fr, en}; - i18n.locale = Localization.locale; + i18n.locale = RNLocalize.findBestAvailableLanguage(["en", "fr"]).languageTag; + console.log(RNLocalize.findBestAvailableLanguage(["en", "fr"]).languageTag); } static getCurrentLocale() { - return Localization.locale; + return RNLocalize.findBestAvailableLanguage(["en", "fr"]).languageTag; } }