diff --git a/src/common/language/format_language.ts b/src/common/language/format_language.ts index 76180912a95b..7230d0991f1e 100644 --- a/src/common/language/format_language.ts +++ b/src/common/language/format_language.ts @@ -12,11 +12,10 @@ export const formatLanguageCode = ( } }; -const formatLanguageCodeMem = memoizeOne((locale: FrontendLocaleData) => - Intl && "DisplayNames" in Intl - ? new Intl.DisplayNames(locale.language, { - type: "language", - fallback: "code", - }) - : undefined +const formatLanguageCodeMem = memoizeOne( + (locale: FrontendLocaleData) => + new Intl.DisplayNames(locale.language, { + type: "language", + fallback: "code", + }) ); diff --git a/src/common/number/format_number.ts b/src/common/number/format_number.ts index 822dfc5411e0..99803081637d 100644 --- a/src/common/number/format_number.ts +++ b/src/common/number/format_number.ts @@ -63,8 +63,7 @@ export const formatNumber = ( if ( localeOptions?.number_format !== NumberFormat.none && - !Number.isNaN(Number(num)) && - Intl + !Number.isNaN(Number(num)) ) { try { return new Intl.NumberFormat( @@ -85,8 +84,7 @@ export const formatNumber = ( if ( !Number.isNaN(Number(num)) && num !== "" && - localeOptions?.number_format === NumberFormat.none && - Intl + localeOptions?.number_format === NumberFormat.none ) { // If NumberFormat is none, use en-US format without grouping. return new Intl.NumberFormat( diff --git a/src/components/ha-country-picker.ts b/src/components/ha-country-picker.ts index f8df7cd9ab16..ac6553c74dc7 100644 --- a/src/components/ha-country-picker.ts +++ b/src/components/ha-country-picker.ts @@ -281,14 +281,10 @@ export class HaCountryPicker extends LitElement { private _getOptions = memoizeOne( (language?: string, countries?: string[]) => { let options: { label: string; value: string }[] = []; - const countryDisplayNames = - Intl && "DisplayNames" in Intl - ? new Intl.DisplayNames(language, { - type: "region", - fallback: "code", - }) - : undefined; - + const countryDisplayNames = new Intl.DisplayNames(language, { + type: "region", + fallback: "code", + }); if (countries) { options = countries.map((country) => ({ value: country, diff --git a/src/components/ha-currency-picker.ts b/src/components/ha-currency-picker.ts index f2f6fea2b323..04b9cd8cba3f 100644 --- a/src/components/ha-currency-picker.ts +++ b/src/components/ha-currency-picker.ts @@ -169,12 +169,9 @@ const CURRENCIES = [ ]; const curSymbol = (currency: string, locale?: string) => - Intl && "NumberFormat" in Intl - ? new Intl.NumberFormat(locale, { style: "currency", currency }) - .formatToParts(1) - .find((x) => x.type === "currency")?.value - : currency; - + new Intl.NumberFormat(locale, { style: "currency", currency }) + .formatToParts(1) + .find((x) => x.type === "currency")?.value; @customElement("ha-currency-picker") export class HaCurrencyPicker extends LitElement { @property() public language = "en"; @@ -188,13 +185,10 @@ export class HaCurrencyPicker extends LitElement { @property({ type: Boolean, reflect: true }) public disabled = false; private _getOptions = memoizeOne((language?: string) => { - const currencyDisplayNames = - Intl && "DisplayNames" in Intl - ? new Intl.DisplayNames(language, { - type: "currency", - fallback: "code", - }) - : undefined; + const currencyDisplayNames = new Intl.DisplayNames(language, { + type: "currency", + fallback: "code", + }); const options = CURRENCIES.map((currency) => ({ value: currency, label: `${