summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-03-24 12:28:08 -0400
committerChristopher Speller <crspeller@gmail.com>2016-03-24 12:28:08 -0400
commit998ce12133358eab587702e258edefbd437f86ba (patch)
treea8d7f7b31cc4e2a232a3134e98ba1c2c85c77115 /webapp
parente5c2915e87d7bdba1d3d76143a375b9a76985960 (diff)
parentd36d977a01b4796be38767d20e5e77283b023453 (diff)
downloadchat-998ce12133358eab587702e258edefbd437f86ba.tar.gz
chat-998ce12133358eab587702e258edefbd437f86ba.tar.bz2
chat-998ce12133358eab587702e258edefbd437f86ba.zip
Merge pull request #2530 from mattermost/i18n-consolidation
Consolidating i18n into i18n.jsx
Diffstat (limited to 'webapp')
-rw-r--r--webapp/i18n/i18n.jsx26
-rw-r--r--webapp/root.jsx23
2 files changed, 29 insertions, 20 deletions
diff --git a/webapp/i18n/i18n.jsx b/webapp/i18n/i18n.jsx
index fde1fbb64..6fed6b831 100644
--- a/webapp/i18n/i18n.jsx
+++ b/webapp/i18n/i18n.jsx
@@ -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);
+}
diff --git a/webapp/root.jsx b/webapp/root.jsx
index f4d9a0e47..2318c0682 100644
--- a/webapp/root.jsx
+++ b/webapp/root.jsx
@@ -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);
}
}