mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-17 21:53:03 +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",
|
"babel-polyfill": "^6.3.14",
|
||||||
"classnames": "^2.1.3",
|
"classnames": "^2.1.3",
|
||||||
"history": "^1.17.0",
|
"history": "^1.17.0",
|
||||||
|
"intl": "^1.2.2",
|
||||||
"intl-format-cache": "^2.0.4",
|
"intl-format-cache": "^2.0.4",
|
||||||
"intl-messageformat": "^1.1.0",
|
"intl-messageformat": "^1.1.0",
|
||||||
"react": "^15.0.0",
|
"react": "^15.0.0",
|
||||||
|
@ -8,6 +8,9 @@ addLocaleData(ruLocaleData);
|
|||||||
|
|
||||||
const SUPPORTED_LANGUAGES = ['ru', 'en'];
|
const SUPPORTED_LANGUAGES = ['ru', 'en'];
|
||||||
const DEFAULT_LANGUAGE = 'en';
|
const DEFAULT_LANGUAGE = 'en';
|
||||||
|
|
||||||
|
const needPolyfill = !window.Intl;
|
||||||
|
|
||||||
function getUserLanguages(userSelectedLang = []) {
|
function getUserLanguages(userSelectedLang = []) {
|
||||||
return [].concat(userSelectedLang || [])
|
return [].concat(userSelectedLang || [])
|
||||||
.concat(navigator.languages || [])
|
.concat(navigator.languages || [])
|
||||||
@ -27,7 +30,20 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
require(locale) {
|
require(locale) {
|
||||||
return new Promise(require(`bundle!i18n/${locale}.json`))
|
const promises = [
|
||||||
.then((messages) => ({locale, messages}));
|
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