-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathi18n.js
More file actions
34 lines (30 loc) · 753 Bytes
/
i18n.js
File metadata and controls
34 lines (30 loc) · 753 Bytes
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
import { initReactI18next } from 'react-i18next'
import AsyncStorage from '@react-native-async-storage/async-storage'
import i18n from 'i18next'
import lang_de from './locale/de/translation.json'
import lang_en from './locale/en/translation.json'
const resources = {
en: {
translation: lang_en
},
de: {
translation: lang_de
}
}
export async function loadLanguage() {
const lng = await AsyncStorage.getItem('language')
i18n
.use(initReactI18next) // passes i18n down to react-i18next
.init({
resources,
lng: lng
? lng
: 'de',
interpolation: {
escapeValue: false // react already safes from xss
},
keySeparator: '>',
nsSeparator: '|'
})
}
export default i18n