-
Notifications
You must be signed in to change notification settings - Fork 0
/
i18n.config.ts
39 lines (34 loc) · 933 Bytes
/
i18n.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import englishTranslation from "./translations/english.json";
import dutchTranslation from "./translations/dutch.json";
import AsyncStorage from "@react-native-async-storage/async-storage";
//empty for now
const resources = {
english: {
translation: englishTranslation,
},
dutch: {
translation: dutchTranslation,
},
};
i18n.use(initReactI18next).init({
compatibilityJSON: 'v3',
resources,
lng: "english", // Default to English
fallbackLng: "english",
interpolation: {
escapeValue: false, // not needed for react!!
},
react: {
useSuspense:false,
},
});
const setLanguage = async () => {
// @ts-ignore
const storedLang: Language = await AsyncStorage.getItem("language");
const languageToSet = storedLang ? storedLang : "english";
i18n.changeLanguage(languageToSet);
}
setLanguage();
export default i18n;