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

View File

@ -4,7 +4,7 @@ import { FlatList } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import RocketChat from '../../lib/rocketchat'; import RocketChat from '../../lib/rocketchat';
import I18n from '../../i18n'; import I18n, { LANGUAGES } from '../../i18n';
import { showErrorAlert } from '../../utils/info'; import { showErrorAlert } from '../../utils/info';
import log, { logEvent, events } from '../../utils/log'; import log, { logEvent, events } from '../../utils/log';
import { setUser as setUserAction } from '../../actions/login'; import { setUser as setUserAction } from '../../actions/login';
@ -20,46 +20,6 @@ import { getUserSelector } from '../../selectors/login';
import database from '../../lib/database'; import database from '../../lib/database';
import SafeAreaView from '../../containers/SafeAreaView'; 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 { class LanguageView extends React.Component {
static navigationOptions = () => ({ static navigationOptions = () => ({
title: I18n.t('Change_Language') title: I18n.t('Change_Language')