[CHORE] Simplify i18n files (#2472)

This commit is contained in:
Diego Mello 2020-09-17 08:50:27 -03:00 committed by GitHub
parent f5a3cb6e1c
commit a8c46094de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 67 deletions

View File

@ -2,33 +2,64 @@ import i18n from 'i18n-js';
import { I18nManager } from 'react-native';
import * as RNLocalize from 'react-native-localize';
import en from './locales/en';
import ru from './locales/ru';
import fr from './locales/fr';
import de from './locales/de';
import nl from './locales/nl';
import ptBR from './locales/pt-BR';
import zhCN from './locales/zh-CN';
import zhTW from './locales/zh_TW';
import ptPT from './locales/pt-PT';
import esES from './locales/es-ES';
import it from './locales/it';
import ja from './locales/ja';
export const LANGUAGES = [
{
label: 'English',
value: 'en',
file: require('./locales/en').default
}, {
label: '简体中文',
value: 'zh-cn',
file: require('./locales/zh-CN').default
}, {
label: '繁體中文',
value: 'zh-tw',
file: require('./locales/zh-TW').default
}, {
label: 'Deutsch',
value: 'de',
file: require('./locales/de').default
}, {
label: 'Español (ES)',
value: 'es',
file: require('./locales/es-ES').default
}, {
label: 'Français',
value: 'fr',
file: require('./locales/fr').default
}, {
label: 'Português (BR)',
value: 'pt-br',
file: require('./locales/pt-BR').default
}, {
label: 'Português (PT)',
value: 'pt',
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
}
];
i18n.translations = {
en,
ru,
'pt-BR': ptBR,
'zh-CN': zhCN,
'zh-TW': zhTW,
fr,
de,
'pt-PT': ptPT,
'es-ES': esES,
nl,
it,
ja
};
const translations = LANGUAGES.reduce((ret, item) => {
ret[item.value] = item.file;
return ret;
}, {});
i18n.translations = translations;
i18n.fallbacks = true;
const defaultLanguage = { languageTag: 'en', isRTL: false };

View File

@ -4,7 +4,7 @@ import { FlatList } from 'react-native';
import { connect } from 'react-redux';
import RocketChat from '../../lib/rocketchat';
import I18n from '../../i18n';
import I18n, { LANGUAGES } from '../../i18n';
import { showErrorAlert } from '../../utils/info';
import log, { logEvent, events } from '../../utils/log';
import { setUser as setUserAction } from '../../actions/login';
@ -20,46 +20,6 @@ import { getUserSelector } from '../../selectors/login';
import database from '../../lib/database';
import SafeAreaView from '../../containers/SafeAreaView';
const LANGUAGES = [
{
label: 'English',
value: 'en'
}, {
label: '简体中文',
value: 'zh-CN'
}, {
label: '繁體中文',
value: 'zh-TW'
}, {
label: 'Deutsch',
value: 'de'
}, {
label: 'Español (ES)',
value: 'es-ES'
}, {
label: 'Français',
value: 'fr'
}, {
label: 'Português (BR)',
value: 'pt-BR'
}, {
label: 'Português (PT)',
value: 'pt-PT'
}, {
label: 'Russian',
value: 'ru'
}, {
label: 'Nederlands',
value: 'nl'
}, {
label: 'Italiano',
value: 'it'
}, {
label: '日本語',
value: 'ja'
}
];
class LanguageView extends React.Component {
static navigationOptions = () => ({
title: I18n.t('Change_Language')