mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 18:56:39 +00:00
exclude a bunch of polyfill locales (#10111)
This commit is contained in:
parent
41a7b42037
commit
e023d60be7
@ -15,8 +15,6 @@ export interface FormatsType {
|
|||||||
time: FormatType;
|
time: FormatType;
|
||||||
}
|
}
|
||||||
|
|
||||||
let loadedPolyfillLocale: Set<string> | undefined;
|
|
||||||
|
|
||||||
const polyfillPluralRules = shouldPolyfillPluralRules();
|
const polyfillPluralRules = shouldPolyfillPluralRules();
|
||||||
const polyfillRelativeTime = shouldPolyfillRelativeTime();
|
const polyfillRelativeTime = shouldPolyfillRelativeTime();
|
||||||
const polyfillDateTime = shouldPolyfillDateTime();
|
const polyfillDateTime = shouldPolyfillDateTime();
|
||||||
@ -41,7 +39,6 @@ let polyfillLoaded = polyfills.length === 0;
|
|||||||
export const polyfillsLoaded = polyfillLoaded
|
export const polyfillsLoaded = polyfillLoaded
|
||||||
? undefined
|
? undefined
|
||||||
: Promise.all(polyfills).then(() => {
|
: Promise.all(polyfills).then(() => {
|
||||||
loadedPolyfillLocale = new Set();
|
|
||||||
polyfillLoaded = true;
|
polyfillLoaded = true;
|
||||||
// Load English so it becomes the default
|
// Load English so it becomes the default
|
||||||
return loadPolyfillLocales("en");
|
return loadPolyfillLocales("en");
|
||||||
@ -132,19 +129,28 @@ export const computeLocalize = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const loadPolyfillLocales = async (language: string) => {
|
export const loadPolyfillLocales = async (language: string) => {
|
||||||
if (!loadedPolyfillLocale || loadedPolyfillLocale.has(language)) {
|
if (!polyfillsLoaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
loadedPolyfillLocale.add(language);
|
await polyfillsLoaded;
|
||||||
try {
|
try {
|
||||||
if (polyfillPluralRules) {
|
if (polyfillPluralRules) {
|
||||||
await import(`@formatjs/intl-pluralrules/locale-data/${language}`);
|
await import(
|
||||||
|
/* webpackExclude: /.+-.+\.js$/ */
|
||||||
|
`@formatjs/intl-pluralrules/locale-data/${language}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (polyfillRelativeTime) {
|
if (polyfillRelativeTime) {
|
||||||
await import(`@formatjs/intl-relativetimeformat/locale-data/${language}`);
|
await import(
|
||||||
|
/* webpackExclude: /.+-.+\.js$/ */
|
||||||
|
`@formatjs/intl-relativetimeformat/locale-data/${language}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (polyfillDateTime) {
|
if (polyfillDateTime) {
|
||||||
await import(`@formatjs/intl-datetimeformat/locale-data/${language}`);
|
await import(
|
||||||
|
/* webpackExclude: /.+-.+\.js$/ */
|
||||||
|
`@formatjs/intl-datetimeformat/locale-data/${language}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
|
Loading…
x
Reference in New Issue
Block a user