keepyourmouthshut/RiderApp/i18n.js

25 lines
738 B
JavaScript
Raw Normal View History

2023-03-20 10:17:25 +00:00
import * as Localization from 'expo-localization'
2023-10-13 11:27:58 +00:00
import AsyncStorage from "@react-native-async-storage/async-storage";
import { Platform } from 'react-native'
2023-03-20 10:17:25 +00:00
import i18n from 'i18n-js'
import { en } from './languages/en'
import { fr } from './languages/fr'
import { km } from './languages/km'
import { zh } from './languages/zh'
import { de } from './languages/de'
import { ar } from './languages/ar'
2023-03-20 10:17:25 +00:00
i18n.initAsync = async () => {
i18n.fallbacks = true
i18n.translations = { fr, en, km, zh, de, ar }
2023-03-20 10:17:25 +00:00
// i18n.locale = 'km'
if (Platform.OS === 'android') {
const lang = await AsyncStorage.getItem('enatega-language')
i18n.locale = lang || 'en'
} else {
i18n.locale = Localization.locale
}
}
export default i18n