Skip to content

Commit

Permalink
Replace Intl polyfill in localize method with loading intl-messagefor…
Browse files Browse the repository at this point in the history
…mat asynchronously
  • Loading branch information
steverep committed May 15, 2024
1 parent 4c42301 commit 8bfaeba
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/common/translations/localize.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -89,9 +89,8 @@ export const computeLocalize = async <Keys extends string = LocalizeKeys>(
resources: Resources,
formats?: FormatsType
): Promise<LocalizeFunc<Keys>> => {
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 = {};
Expand Down

0 comments on commit 8bfaeba

Please sign in to comment.