|
@@ -0,0 +1,26 @@
|
|
1
|
+import I18n from "ex-react-native-i18n";
|
|
2
|
+import { Localization } from 'expo-localization'
|
|
3
|
+import { I18nManager } from "react-native";
|
|
4
|
+
|
|
5
|
+import en from './en.json'
|
|
6
|
+import es from './es.json'
|
|
7
|
+
|
|
8
|
+I18n.translations = {
|
|
9
|
+ en,
|
|
10
|
+ es
|
|
11
|
+}
|
|
12
|
+
|
|
13
|
+const getLanguage = async() => {
|
|
14
|
+ try { const choice = await Localization.locale
|
|
15
|
+ I18n.locale = choice.substr(0, 2)
|
|
16
|
+ I18n.initAsync()
|
|
17
|
+ }catch(error){
|
|
18
|
+ console.log('Unable to get locale')
|
|
19
|
+ }
|
|
20
|
+}
|
|
21
|
+
|
|
22
|
+getLanguage()
|
|
23
|
+
|
|
24
|
+export function t(name){
|
|
25
|
+ return I18n.t(name)
|
|
26
|
+}
|