-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathi18n.tsx
More file actions
30 lines (23 loc) · 810 Bytes
/
i18n.tsx
File metadata and controls
30 lines (23 loc) · 810 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
import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
import * as RNLocalize from 'react-native-localize';
import translationEnglish from './resources/i18n/locale_en.json';
import translationChinese from './resources/i18n/locale_zh_CN.json';
const resources = {
en: { translation: translationEnglish },
zh_CN: { translation: translationChinese },
};
const locales = RNLocalize.getLocales();
let defaultLang = 'en';
if (Array.isArray(locales)) {
defaultLang = locales[0].languageTag.startsWith('zh-CN') ? 'zh_CN' : 'en';
}
i18next.use(initReactI18next).init({
compatibilityJSON: 'v3', resources, lng: defaultLang, fallbackLng: 'en', interpolation: {
escapeValue: false,
},
react: {
useSuspense: false,
},
});
export default i18next;