mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Merge pull request #2530 from mattermost/i18n-consolidation
Consolidating i18n into i18n.jsx
This commit is contained in:
@@ -4,6 +4,11 @@
|
||||
const es = require('!!file?name=i18n/[name].[ext]!./es.json');
|
||||
const pt = require('!!file?name=i18n/[name].[ext]!./pt.json');
|
||||
|
||||
import {addLocaleData} from 'react-intl';
|
||||
import enLocaleData from 'react-intl/locale-data/en';
|
||||
import esLocaleData from 'react-intl/locale-data/es';
|
||||
import ptLocaleData from 'react-intl/locale-data/pt';
|
||||
|
||||
const languages = {
|
||||
en: {
|
||||
value: 'en',
|
||||
@@ -29,3 +34,24 @@ export function getLanguages() {
|
||||
export function getLanguageInfo(locale) {
|
||||
return languages[locale];
|
||||
}
|
||||
|
||||
export function safariFix(callback) {
|
||||
require.ensure([
|
||||
'intl',
|
||||
'intl/locale-data/jsonp/en.js',
|
||||
'intl/locale-data/jsonp/es.js',
|
||||
'intl/locale-data/jsonp/pt.js'
|
||||
], (require) => {
|
||||
require('intl');
|
||||
require('intl/locale-data/jsonp/en.js');
|
||||
require('intl/locale-data/jsonp/es.js');
|
||||
require('intl/locale-data/jsonp/pt.js');
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
export function doAddLocaleData() {
|
||||
addLocaleData(enLocaleData);
|
||||
addLocaleData(esLocaleData);
|
||||
addLocaleData(ptLocaleData);
|
||||
}
|
||||
|
||||
@@ -52,10 +52,7 @@ import OAuthToEmail from 'components/claim/components/oauth_to_email.jsx';
|
||||
import LDAPToEmail from 'components/claim/components/ldap_to_email.jsx';
|
||||
import EmailToLDAP from 'components/claim/components/email_to_ldap.jsx';
|
||||
|
||||
import {addLocaleData} from 'react-intl';
|
||||
import enLocaleData from 'react-intl/locale-data/en';
|
||||
import esLocaleData from 'react-intl/locale-data/es';
|
||||
import ptLocaleData from 'react-intl/locale-data/pt';
|
||||
import * as I18n from 'i18n/i18n.jsx';
|
||||
|
||||
// This is for anything that needs to be done for ALL react components.
|
||||
// This runs before we start to render anything.
|
||||
@@ -115,28 +112,14 @@ function preRenderSetup(callwhendone) {
|
||||
);
|
||||
|
||||
function afterIntl() {
|
||||
addLocaleData(enLocaleData);
|
||||
addLocaleData(esLocaleData);
|
||||
addLocaleData(ptLocaleData);
|
||||
|
||||
I18n.doAddLocaleData();
|
||||
$.when(d1, d2).done(callwhendone);
|
||||
}
|
||||
|
||||
if (global.Intl) {
|
||||
afterIntl();
|
||||
} else {
|
||||
require.ensure([
|
||||
'intl',
|
||||
'intl/locale-data/jsonp/en.js',
|
||||
'intl/locale-data/jsonp/es.js',
|
||||
'intl/locale-data/jsonp/pt.js'
|
||||
], (require) => {
|
||||
require('intl');
|
||||
require('intl/locale-data/jsonp/en.js');
|
||||
require('intl/locale-data/jsonp/es.js');
|
||||
require('intl/locale-data/jsonp/pt.js');
|
||||
afterIntl();
|
||||
});
|
||||
I18n.safarifix(afterIntl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user