From fe48ca5188807ef3ad39549b3623cc7a136a731e Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Wed, 15 May 2024 22:21:19 +0000 Subject: [PATCH] Replace Intl polyfill in localize method with loading intl-messageformat asynchronously --- src/common/translations/localize.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/common/translations/localize.ts b/src/common/translations/localize.ts index a7fff080b2ff..92cf302ffae5 100644 --- a/src/common/translations/localize.ts +++ b/src/common/translations/localize.ts @@ -1,4 +1,4 @@ -import IntlMessageFormat from "intl-messageformat"; +import type { IntlMessageFormat } from "intl-messageformat"; import type { HTMLTemplateResult } from "lit"; import { polyfillLocaleData } from "../../resources/polyfills/locale-data-polyfill"; import { Resources, TranslationDict } from "../../types"; @@ -89,9 +89,8 @@ export const computeLocalize = async ( resources: Resources, formats?: FormatsType ): Promise> => { - await import("../../resources/polyfills/intl-polyfill").then(() => - polyfillLocaleData(language) - ); + const { IntlMessageFormat } = await import("intl-messageformat"); + await polyfillLocaleData(language); // Every time any of the parameters change, invalidate the strings cache. cache._localizationCache = {};