Files
mattermost/webapp/i18n/i18n.jsx

198 lines
5.6 KiB
React
Raw Normal View History

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
2016-03-14 08:50:46 -04:00
// See License.txt for license information.
const de = require('!!file-loader?name=i18n/[name].[hash].[ext]!./de.json');
const es = require('!!file-loader?name=i18n/[name].[hash].[ext]!./es.json');
const fr = require('!!file-loader?name=i18n/[name].[hash].[ext]!./fr.json');
const ja = require('!!file-loader?name=i18n/[name].[hash].[ext]!./ja.json');
const ko = require('!!file-loader?name=i18n/[name].[hash].[ext]!./ko.json');
const nl = require('!!file-loader?name=i18n/[name].[hash].[ext]!./nl.json');
const pl = require('!!file-loader?name=i18n/[name].[hash].[ext]!./pl.json');
const pt_BR = require('!!file-loader?name=i18n/[name].[hash].[ext]!./pt-BR.json'); //eslint-disable-line camelcase
const tr = require('!!file-loader?name=i18n/[name].[hash].[ext]!./tr.json');
const ru = require('!!file-loader?name=i18n/[name].[hash].[ext]!./ru.json');
const zh_TW = require('!!file-loader?name=i18n/[name].[hash].[ext]!./zh-TW.json'); //eslint-disable-line camelcase
const zh_CN = require('!!file-loader?name=i18n/[name].[hash].[ext]!./zh-CN.json'); //eslint-disable-line camelcase
2016-03-14 08:50:46 -04:00
2016-03-24 12:05:50 -04:00
import {addLocaleData} from 'react-intl';
2016-06-14 14:53:26 -03:00
import deLocaleData from 'react-intl/locale-data/de';
2016-03-24 12:05:50 -04:00
import enLocaleData from 'react-intl/locale-data/en';
import esLocaleData from 'react-intl/locale-data/es';
import frLocaleData from 'react-intl/locale-data/fr';
import jaLocaleData from 'react-intl/locale-data/ja';
2016-08-04 10:45:36 -05:00
import koLocaleData from 'react-intl/locale-data/ko';
2016-07-22 13:05:26 -04:00
import nlLocaleData from 'react-intl/locale-data/nl';
import plLocaleData from 'react-intl/locale-data/pl';
2016-03-24 12:05:50 -04:00
import ptLocaleData from 'react-intl/locale-data/pt';
import trLocaleData from 'react-intl/locale-data/tr';
2016-10-12 10:49:17 -03:00
import ruLocaleData from 'react-intl/locale-data/ru';
2016-07-19 08:34:22 -04:00
import zhLocaleData from 'react-intl/locale-data/zh';
2016-03-24 12:05:50 -04:00
// should match the values in model/config.go
2016-03-14 08:50:46 -04:00
const languages = {
2016-06-14 14:53:26 -03:00
de: {
value: 'de',
2016-11-11 16:55:23 -03:00
name: 'Deutsch',
order: 0,
2016-06-14 14:53:26 -03:00
url: de
},
2016-03-14 08:50:46 -04:00
en: {
value: 'en',
name: 'English',
order: 1,
2016-03-14 08:50:46 -04:00
url: ''
},
es: {
value: 'es',
2016-08-04 10:45:36 -05:00
name: 'Español',
order: 2,
2016-03-14 08:50:46 -04:00
url: es
},
fr: {
value: 'fr',
2016-11-11 16:55:23 -03:00
name: 'Français',
order: 3,
url: fr
},
ja: {
value: 'ja',
2016-11-11 16:55:23 -03:00
name: '日本語',
order: 12,
url: ja
},
2016-08-04 10:45:36 -05:00
ko: {
value: 'ko',
2016-11-11 16:55:23 -03:00
name: '한국어 (Alpha)',
order: 9,
2016-08-04 10:45:36 -05:00
url: ko
},
2016-07-22 13:05:26 -04:00
nl: {
value: 'nl',
name: 'Nederlands (Alpha)',
order: 4,
2016-07-22 13:05:26 -04:00
url: nl
},
pl: {
value: 'pl',
name: 'Polski (Beta)',
order: 5,
url: pl
},
'pt-BR': {
value: 'pt-BR',
2016-08-04 10:45:36 -05:00
name: 'Português (Brasil)',
order: 6,
url: pt_BR
2016-07-19 08:34:22 -04:00
},
tr: {
value: 'tr',
name: 'Türkçe (Beta)',
order: 7,
url: tr
},
2016-10-12 10:49:17 -03:00
ru: {
value: 'ru',
name: 'Pусский (Beta)',
order: 8,
2016-10-12 10:49:17 -03:00
url: ru
},
2016-07-19 08:34:22 -04:00
'zh-TW': {
value: 'zh-TW',
2016-11-11 16:55:23 -03:00
name: '中文 (繁體)',
order: 11,
2016-07-19 08:34:22 -04:00
url: zh_TW
2016-08-04 10:45:36 -05:00
},
'zh-CN': {
value: 'zh-CN',
2016-11-11 16:55:23 -03:00
name: '中文 (简体)',
order: 10,
2016-08-04 10:45:36 -05:00
url: zh_CN
2016-03-14 08:50:46 -04:00
}
};
let availableLanguages = null;
function setAvailableLanguages() {
let available;
availableLanguages = {};
if (global.window.mm_config.AvailableLocales) {
available = global.window.mm_config.AvailableLocales.split(',');
} else {
available = Object.keys(languages);
}
available.forEach((l) => {
if (languages[l]) {
availableLanguages[l] = languages[l];
}
});
}
export function getAllLanguages() {
return languages;
}
export function getLanguages() {
if (!availableLanguages) {
setAvailableLanguages();
}
return availableLanguages;
}
2016-03-14 08:50:46 -04:00
export function getLanguageInfo(locale) {
return getAllLanguages()[locale];
}
export function isLanguageAvailable(locale) {
return Boolean(getLanguages()[locale]);
2016-03-14 08:50:46 -04:00
}
2016-03-24 12:05:50 -04:00
export function safariFix(callback) {
require.ensure([
'intl',
2016-06-14 14:53:26 -03:00
'intl/locale-data/jsonp/de.js',
2016-03-24 12:05:50 -04:00
'intl/locale-data/jsonp/en.js',
'intl/locale-data/jsonp/es.js',
'intl/locale-data/jsonp/fr.js',
'intl/locale-data/jsonp/ja.js',
2016-08-04 10:45:36 -05:00
'intl/locale-data/jsonp/ko.js',
2016-07-22 13:05:26 -04:00
'intl/locale-data/jsonp/nl.js',
'intl/locale-data/jsonp/pl.js',
2016-07-19 08:34:22 -04:00
'intl/locale-data/jsonp/pt.js',
'intl/locale-data/jsonp/tr.js',
2016-10-12 10:49:17 -03:00
'intl/locale-data/jsonp/ru.js',
2016-07-19 08:34:22 -04:00
'intl/locale-data/jsonp/zh.js'
2016-03-24 12:05:50 -04:00
], (require) => {
require('intl');
2016-06-14 14:53:26 -03:00
require('intl/locale-data/jsonp/de.js');
2016-03-24 12:05:50 -04:00
require('intl/locale-data/jsonp/en.js');
require('intl/locale-data/jsonp/es.js');
require('intl/locale-data/jsonp/fr.js');
require('intl/locale-data/jsonp/ja.js');
2016-08-04 10:45:36 -05:00
require('intl/locale-data/jsonp/ko.js');
2016-07-22 13:05:26 -04:00
require('intl/locale-data/jsonp/nl.js');
require('intl/locale-data/jsonp/pl.js');
2016-03-24 12:05:50 -04:00
require('intl/locale-data/jsonp/pt.js');
require('intl/locale-data/jsonp/tr.js');
2016-10-12 10:49:17 -03:00
require('intl/locale-data/jsonp/ru.js');
2016-07-19 08:34:22 -04:00
require('intl/locale-data/jsonp/zh.js');
2016-03-24 12:05:50 -04:00
callback();
});
}
export function doAddLocaleData() {
addLocaleData(enLocaleData);
2016-06-14 14:53:26 -03:00
addLocaleData(deLocaleData);
2016-03-24 12:05:50 -04:00
addLocaleData(esLocaleData);
addLocaleData(frLocaleData);
addLocaleData(jaLocaleData);
2016-08-04 10:45:36 -05:00
addLocaleData(koLocaleData);
2016-07-22 13:05:26 -04:00
addLocaleData(nlLocaleData);
addLocaleData(plLocaleData);
2016-03-24 12:05:50 -04:00
addLocaleData(ptLocaleData);
addLocaleData(trLocaleData);
2016-10-12 10:49:17 -03:00
addLocaleData(ruLocaleData);
2016-07-19 08:34:22 -04:00
addLocaleData(zhLocaleData);
2016-03-24 12:05:50 -04:00
}