mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-27 23:40:28 +05:30
#75: intl polyfill for safari and old ie
This commit is contained in:
parent
26cb65f653
commit
98211a7ecf
@ -19,6 +19,7 @@
|
||||
"babel-polyfill": "^6.3.14",
|
||||
"classnames": "^2.1.3",
|
||||
"history": "^1.17.0",
|
||||
"intl": "^1.2.2",
|
||||
"intl-format-cache": "^2.0.4",
|
||||
"intl-messageformat": "^1.1.0",
|
||||
"react": "^15.0.0",
|
||||
|
@ -8,6 +8,9 @@ addLocaleData(ruLocaleData);
|
||||
|
||||
const SUPPORTED_LANGUAGES = ['ru', 'en'];
|
||||
const DEFAULT_LANGUAGE = 'en';
|
||||
|
||||
const needPolyfill = !window.Intl;
|
||||
|
||||
function getUserLanguages(userSelectedLang = []) {
|
||||
return [].concat(userSelectedLang || [])
|
||||
.concat(navigator.languages || [])
|
||||
@ -27,7 +30,20 @@ export default {
|
||||
},
|
||||
|
||||
require(locale) {
|
||||
return new Promise(require(`bundle!i18n/${locale}.json`))
|
||||
.then((messages) => ({locale, messages}));
|
||||
const promises = [
|
||||
new Promise(require(`bundle!i18n/${locale}.json`))
|
||||
];
|
||||
|
||||
if (needPolyfill) {
|
||||
promises.push(new Promise((resolve) => {
|
||||
require.ensure([], () => {
|
||||
require('intl');
|
||||
require(`bundle!intl/locale-data/jsonp/${locale}.js`)(resolve);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
return Promise.all(promises)
|
||||
.then(([messages]) => ({locale, messages}));
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user