2019-07-16 14:30:29 +00:00
|
|
|
import i18n from 'i18n-js';
|
|
|
|
import { I18nManager } from 'react-native';
|
|
|
|
import * as RNLocalize from 'react-native-localize';
|
|
|
|
|
2020-11-30 21:47:05 +00:00
|
|
|
export * from './isRTL';
|
|
|
|
|
2020-09-17 11:50:27 +00:00
|
|
|
export const LANGUAGES = [
|
|
|
|
{
|
|
|
|
label: 'English',
|
|
|
|
value: 'en',
|
|
|
|
file: require('./locales/en').default
|
|
|
|
}, {
|
|
|
|
label: '简体中文',
|
2020-09-24 14:13:23 +00:00
|
|
|
value: 'zh-CN',
|
2020-09-17 11:50:27 +00:00
|
|
|
file: require('./locales/zh-CN').default
|
|
|
|
}, {
|
|
|
|
label: '繁體中文',
|
2020-09-24 14:13:23 +00:00
|
|
|
value: 'zh-TW',
|
2020-09-17 11:50:27 +00:00
|
|
|
file: require('./locales/zh-TW').default
|
|
|
|
}, {
|
|
|
|
label: 'Deutsch',
|
|
|
|
value: 'de',
|
|
|
|
file: require('./locales/de').default
|
|
|
|
}, {
|
|
|
|
label: 'Español (ES)',
|
2020-09-24 14:13:23 +00:00
|
|
|
value: 'es-ES',
|
2020-09-17 11:50:27 +00:00
|
|
|
file: require('./locales/es-ES').default
|
|
|
|
}, {
|
|
|
|
label: 'Français',
|
|
|
|
value: 'fr',
|
|
|
|
file: require('./locales/fr').default
|
|
|
|
}, {
|
|
|
|
label: 'Português (BR)',
|
2020-09-24 14:13:23 +00:00
|
|
|
value: 'pt-BR',
|
2020-09-17 11:50:27 +00:00
|
|
|
file: require('./locales/pt-BR').default
|
|
|
|
}, {
|
|
|
|
label: 'Português (PT)',
|
2020-09-24 14:13:23 +00:00
|
|
|
value: 'pt-PT',
|
2020-09-17 11:50:27 +00:00
|
|
|
file: require('./locales/pt-PT').default
|
|
|
|
}, {
|
|
|
|
label: 'Russian',
|
|
|
|
value: 'ru',
|
|
|
|
file: require('./locales/ru').default
|
|
|
|
}, {
|
|
|
|
label: 'Nederlands',
|
|
|
|
value: 'nl',
|
|
|
|
file: require('./locales/nl').default
|
|
|
|
}, {
|
|
|
|
label: 'Italiano',
|
|
|
|
value: 'it',
|
|
|
|
file: require('./locales/it').default
|
|
|
|
}, {
|
|
|
|
label: '日本語',
|
|
|
|
value: 'ja',
|
|
|
|
file: require('./locales/ja').default
|
2020-12-01 17:50:59 +00:00
|
|
|
}, {
|
|
|
|
label: 'العربية',
|
|
|
|
value: 'ar',
|
|
|
|
file: require('./locales/ar').default
|
2021-01-20 21:07:45 +00:00
|
|
|
}, {
|
|
|
|
label: 'Türkçe',
|
|
|
|
value: 'tr',
|
|
|
|
file: require('./locales/tr').default
|
2020-09-17 11:50:27 +00:00
|
|
|
}
|
|
|
|
];
|
2018-06-01 17:38:13 +00:00
|
|
|
|
2020-09-17 11:50:27 +00:00
|
|
|
const translations = LANGUAGES.reduce((ret, item) => {
|
|
|
|
ret[item.value] = item.file;
|
|
|
|
return ret;
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
i18n.translations = translations;
|
2019-07-16 14:30:29 +00:00
|
|
|
i18n.fallbacks = true;
|
|
|
|
|
|
|
|
const defaultLanguage = { languageTag: 'en', isRTL: false };
|
|
|
|
const availableLanguages = Object.keys(i18n.translations);
|
|
|
|
const { languageTag, isRTL } = RNLocalize.findBestAvailableLanguage(availableLanguages) || defaultLanguage;
|
|
|
|
|
|
|
|
I18nManager.forceRTL(isRTL);
|
2020-11-30 21:47:05 +00:00
|
|
|
I18nManager.swapLeftAndRightInRTL(isRTL);
|
2019-07-16 14:30:29 +00:00
|
|
|
i18n.locale = languageTag;
|
2020-11-30 21:47:05 +00:00
|
|
|
i18n.isRTL = I18nManager.isRTL;
|
2018-06-01 17:38:13 +00:00
|
|
|
|
2019-07-16 14:30:29 +00:00
|
|
|
export default i18n;
|