Repository URL to install this package:
|
Version:
5.0.0-rc.15 ▾
|
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.extractIntlLocaleData = extractIntlLocaleData;
exports.importIntl = importIntl;
var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime/helpers/interopRequireWildcard"));
var _utils = require("./utils");
function extractIntlLocaleData(reactIntlLocaleData, locale) {
const normalizedLocale = (0, _utils.normalizeLocale)(locale);
const [language] = normalizedLocale.split('-'); // react-intl's locale data provides additional specific locales, i.e. `en-GB`: we'll pick the base locale data
const [specificLocaleData] = reactIntlLocaleData.default.filter(localeData => localeData.locale === normalizedLocale);
const defaultLocaleData = reactIntlLocaleData.default.filter(localeData => localeData.locale === language);
return specificLocaleData || defaultLocaleData;
}
/**
* Dynamic import of the `Intl` polyfill, but only if there is no support
*/
async function importIntl() {
if (!global.Intl) {
await Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('intl')));
}
}
//# sourceMappingURL=import.js.map