From b2d97c24ab7f4212cd5c080e1ea709ce10c87020 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Mon, 25 Sep 2023 16:20:07 -0700 Subject: [PATCH 01/12] don't allow old localization format (+ caching update) --- hassio/src/supervisor-base-element.ts | 10 ++---- src/common/translations/localize.ts | 47 ++++++++------------------- src/fake_data/provide_hass.ts | 2 +- src/mixins/lit-localize-lite-mixin.ts | 6 +--- src/state/translations-mixin.ts | 2 +- 5 files changed, 20 insertions(+), 47 deletions(-) diff --git a/hassio/src/supervisor-base-element.ts b/hassio/src/supervisor-base-element.ts index 9402728160de..358a7cc273d4 100644 --- a/hassio/src/supervisor-base-element.ts +++ b/hassio/src/supervisor-base-element.ts @@ -106,13 +106,9 @@ export class SupervisorBaseElement extends urlSyncMixin( const { language, data } = await getTranslation(null, this._language); this._updateSupervisor({ - localize: await computeLocalize( - this.constructor.prototype, - language, - { - [language]: data, - } - ), + localize: await computeLocalize(language, { + [language]: data, + }), }); } diff --git a/src/common/translations/localize.ts b/src/common/translations/localize.ts index c53d2862c870..f40c11b8ea48 100644 --- a/src/common/translations/localize.ts +++ b/src/common/translations/localize.ts @@ -42,7 +42,7 @@ export type FlattenObjectKeys< export type LocalizeFunc = ( key: Keys, - ...args: any[] + values?: Record ) => string; interface FormatType { @@ -54,29 +54,9 @@ export interface FormatsType { time: FormatType; } -/** - * Adapted from Polymer app-localize-behavior. - * - * Copyright (c) 2016 The Polymer Project Authors. All rights reserved. - * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt - * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt - * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt - * Code distributed by Google as part of the polymer project is also - * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt - */ - -/** - * Optional dictionary of user defined formats, as explained here: - * http://formatjs.io/guides/message-syntax/#custom-formats - * - * For example, a valid dictionary of formats would be: - * this.formats = { - * number: { USD: { style: 'currency', currency: 'USD' } } - * } - */ +let localizationCache: Record = {}; export const computeLocalize = async ( - cache: any, language: string, resources: Resources, formats?: FormatsType @@ -85,26 +65,23 @@ export const computeLocalize = async ( polyfillLocaleData(language) ); - // Every time any of the parameters change, invalidate the strings cache. - cache._localizationCache = {}; + // Don't keep around strings from the previous language + localizationCache = {}; - return (key, ...args) => { + return (key, ..._args) => { if (!key || !resources || !language || !resources[language]) { return ""; } - // Cache the key/value pairs for the same language, so that we don't - // do extra work if we're just reusing strings across an application. const translatedValue = resources[language][key]; if (!translatedValue) { return ""; } - const messageKey = key + translatedValue; - let translatedMessage = cache._localizationCache[messageKey] as - | IntlMessageFormat - | undefined; + // Cache the key/value pairs for the same language, so that we don't + // do extra work if we're just reusing strings across an application. + let translatedMessage = localizationCache[translatedValue]; if (!translatedMessage) { try { @@ -116,13 +93,17 @@ export const computeLocalize = async ( } catch (err: any) { return "Translation error: " + err.message; } - cache._localizationCache[messageKey] = translatedMessage; + localizationCache[translatedValue] = translatedMessage; } let argObject = {}; + // TS says that we will always get the new format, but we might get the old format + const args = _args as any; if (args.length === 1 && typeof args[0] === "object") { argObject = args[0]; - } else { + } else if (args.length >= 2) { + // eslint-disable-next-line no-console + console.warn("[FIXME] While localizing", key, "old format was passed"); for (let i = 0; i < args.length; i += 2) { argObject[args[i]] = args[i + 1]; } diff --git a/src/fake_data/provide_hass.ts b/src/fake_data/provide_hass.ts index 297f4d4f8c71..d40d0ef3488c 100644 --- a/src/fake_data/provide_hass.ts +++ b/src/fake_data/provide_hass.ts @@ -99,7 +99,7 @@ export const provideHass = ( resources, }); hass().updateHass({ - localize: await computeLocalize(elements[0], lang, hass().resources), + localize: await computeLocalize(lang, hass().resources), }); fireEvent(window, "translations-updated"); } diff --git a/src/mixins/lit-localize-lite-mixin.ts b/src/mixins/lit-localize-lite-mixin.ts index 2259a23dfff9..b5a80e633c9b 100644 --- a/src/mixins/lit-localize-lite-mixin.ts +++ b/src/mixins/lit-localize-lite-mixin.ts @@ -52,11 +52,7 @@ export const litLocalizeLiteMixin = >( (changedProperties.has("language") || changedProperties.has("_resources")) ) { - computeLocalize( - this.constructor.prototype, - this.language, - this._resources - ).then((localize) => { + computeLocalize(this.language, this._resources).then((localize) => { this.localize = localize; }); } diff --git a/src/state/translations-mixin.ts b/src/state/translations-mixin.ts index 66b86a140a25..86e87502dbea 100644 --- a/src/state/translations-mixin.ts +++ b/src/state/translations-mixin.ts @@ -446,7 +446,7 @@ export default >(superClass: T) => // Update resources immediately, so when a new update comes in we don't miss values this._updateHass({ resources }); - const localize = await computeLocalize(this, language, resources); + const localize = await computeLocalize(language, resources); if ( updateResourcesIteration !== i || From 89e3cbf29a43e8e2e39810b50e00ec800f2688e8 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Mon, 25 Sep 2023 16:52:22 -0700 Subject: [PATCH 02/12] fix old localization format --- demo/src/custom-cards/ha-demo-card.ts | 3 +- .../addon-store/hassio-addon-repository.ts | 8 +- .../addon-view/config/hassio-addon-config.ts | 16 +- .../addon-view/config/hassio-addon-network.ts | 16 +- .../hassio-addon-documentation-tab.ts | 3 +- .../src/addon-view/info/hassio-addon-info.ts | 72 ++++---- .../src/addon-view/log/hassio-addon-logs.ts | 8 +- hassio/src/backups/hassio-backups.ts | 8 +- hassio/src/dashboard/hassio-update.ts | 8 +- .../backup/dialog-hassio-create-backup.ts | 3 +- .../dialogs/network/dialog-hassio-network.ts | 3 +- hassio/src/hassio-my-redirect.ts | 10 +- hassio/src/system/hassio-core-info.ts | 34 ++-- hassio/src/system/hassio-supervisor-info.ts | 43 ++--- hassio/src/system/hassio-supervisor-log.ts | 11 +- src/auth/ha-auth-flow.ts | 21 +-- src/common/structs/handle-errors.ts | 44 ++--- .../ha-button-related-filter-menu.ts | 21 ++- .../media-player/ha-media-player-browse.ts | 10 +- src/data/application_credential.ts | 2 +- src/data/device_automation.ts | 48 +++--- src/data/device_registry.ts | 10 +- src/data/logbook.ts | 10 +- .../dialog-config-entry-system-options.ts | 29 ++-- .../config-flow/show-dialog-config-flow.ts | 3 +- .../config-flow/step-flow-create-entry.ts | 3 +- .../configurator-notification-item.ts | 8 +- src/dialogs/quick-bar/ha-quick-bar.ts | 17 +- src/layouts/hass-tabs-subpage-data-table.ts | 8 +- .../ha-config-application-credentials.ts | 6 +- .../config/areas/ha-config-areas-dashboard.ts | 47 +++--- .../action/ha-automation-action-row.ts | 10 +- .../types/ha-automation-action-choose.ts | 6 +- .../ha-automation-condition-editor.ts | 3 +- .../config/automation/ha-automation-editor.ts | 3 +- .../config/automation/ha-automation-picker.ts | 16 +- .../trigger/ha-automation-trigger-row.ts | 3 +- .../blueprint/dialog-import-blueprint.ts | 8 +- .../config/cloud/account/cloud-tts-pref.ts | 8 +- .../cloud/account/dialog-cloud-tts-try.ts | 3 +- .../core/ha-config-system-navigation.ts | 72 +++----- .../config/dashboard/ha-config-dashboard.ts | 22 +-- .../device-detail/ha-device-entities-card.ts | 3 +- .../device-detail/ha-device-info-card.ts | 19 +-- .../ha-device-via-devices-card.ts | 3 +- .../mqtt/dialog-mqtt-device-debug-info.ts | 15 +- .../zwave_js/ha-device-info-zwave_js.ts | 3 +- .../dialog-device-registry-detail.ts | 33 ++-- .../config/devices/ha-config-device-page.ts | 155 ++++++++---------- .../devices/ha-config-devices-dashboard.ts | 3 +- .../settings/entity-settings-helper-tab.ts | 3 +- .../entity-registry-settings-editor.ts | 41 +++-- .../entities/entity-registry-settings.ts | 3 +- .../config/entities/ha-config-entities.ts | 29 ++-- .../config/helpers/dialog-helper-detail.ts | 13 +- src/panels/config/info/ha-config-info.ts | 5 +- .../integrations/ha-config-flow-card.ts | 3 +- .../ha-config-integration-page.ts | 21 +-- .../ha-ignored-config-entry-card.ts | 3 +- .../integrations/ha-integration-card.ts | 9 +- .../mqtt/mqtt-subscribe-card.ts | 18 +- .../integration-panels/zha/zha-device-card.ts | 11 +- .../zha/zha-device-pairing-status-card.ts | 8 +- .../dialog-zwave_js-remove-failed-node.ts | 3 +- .../zwave_js/dialog-zwave_js-remove-node.ts | 3 +- .../zwave_js/zwave_js-node-config.ts | 24 +-- .../config/logs/dialog-system-log-detail.ts | 10 +- src/panels/config/logs/error-log-card.ts | 6 +- src/panels/config/logs/system-log-card.ts | 14 +- .../config/network/supervisor-network.ts | 3 +- .../config/person/dialog-person-detail.ts | 3 +- src/panels/config/scene/ha-scene-editor.ts | 3 +- src/panels/config/script/ha-script-editor.ts | 11 +- src/panels/config/script/ha-script-picker.ts | 24 ++- src/panels/config/tags/dialog-tag-detail.ts | 18 +- src/panels/config/tags/ha-config-tags.ts | 26 ++- src/panels/config/users/ha-config-users.ts | 3 +- .../voice-assistants/cloud-alexa-pref.ts | 13 +- .../ha-config-voice-assistants-expose.ts | 6 +- src/panels/custom/ha-panel-custom.ts | 5 +- .../event/event-subscribe-card.ts | 3 +- .../service/developer-tools-service.ts | 8 +- .../developer-yaml-config.ts | 3 +- src/panels/lovelace/cards/hui-gauge-card.ts | 6 +- src/panels/lovelace/cards/hui-logbook-card.ts | 8 +- .../cards/hui-weather-forecast-card.ts | 8 +- src/panels/lovelace/common/compute-tooltip.ts | 67 +++----- .../common/generate-lovelace-config.ts | 10 +- src/panels/lovelace/common/handle-action.ts | 11 +- src/panels/lovelace/components/hui-warning.ts | 8 +- .../card-editor/hui-dialog-create-card.ts | 3 +- .../card-editor/hui-dialog-edit-card.ts | 12 +- .../hui-dialog-create-headerfooter.ts | 9 +- .../lovelace/editor/hui-element-editor.ts | 8 +- .../view-editor/hui-dialog-edit-view.ts | 11 +- .../elements/hui-state-label-element.ts | 5 +- .../entity-rows/hui-script-entity-row.ts | 11 +- src/panels/lovelace/hui-editor.ts | 12 +- src/panels/mailbox/ha-panel-mailbox.ts | 8 +- src/panels/my/ha-panel-my.ts | 101 +++++------- .../dialog-ha-mfa-module-setup-flow.ts | 3 +- .../ha-long-lived-access-token-dialog.ts | 3 +- .../ha-long-lived-access-tokens-card.ts | 14 +- src/panels/profile/ha-mfa-modules-card.ts | 8 +- src/state-summary/state-card-script.ts | 11 +- src/state/disconnect-toast-mixin.ts | 8 +- src/translations/en.json | 2 +- 107 files changed, 667 insertions(+), 957 deletions(-) diff --git a/demo/src/custom-cards/ha-demo-card.ts b/demo/src/custom-cards/ha-demo-card.ts index 92f1731b71e8..951a072859e7 100644 --- a/demo/src/custom-cards/ha-demo-card.ts +++ b/demo/src/custom-cards/ha-demo-card.ts @@ -48,8 +48,7 @@ export class HADemoCard extends LitElement implements LovelaceCard { ${this.hass.localize( "ui.panel.page-demo.cards.demo.demo_by", - "name", - conf.authorName + { name: conf.authorName } )} diff --git a/hassio/src/addon-store/hassio-addon-repository.ts b/hassio/src/addon-store/hassio-addon-repository.ts index 728668ebd9ec..cd0e1d234da4 100644 --- a/hassio/src/addon-store/hassio-addon-repository.ts +++ b/hassio/src/addon-store/hassio-addon-repository.ts @@ -49,11 +49,9 @@ export class HassioAddonRepositoryEl extends LitElement { return html`

- ${this.supervisor.localize( - "store.no_results_found", - "repository", - repo.name - )} + ${this.supervisor.localize("store.no_results_found", { + repository: repo.name, + })}

`; diff --git a/hassio/src/addon-view/config/hassio-addon-config.ts b/hassio/src/addon-view/config/hassio-addon-config.ts index 59c0e3fc63d5..ceb56cbd758b 100644 --- a/hassio/src/addon-view/config/hassio-addon-config.ts +++ b/hassio/src/addon-view/config/hassio-addon-config.ts @@ -340,11 +340,9 @@ class HassioAddonConfig extends LitElement { }; fireEvent(this, "hass-api-called", eventdata); } catch (err: any) { - this._error = this.supervisor.localize( - "addon.failed_to_reset", - "error", - extractApiErrorMessage(err) - ); + this._error = this.supervisor.localize("addon.failed_to_reset", { + error: extractApiErrorMessage(err), + }); } button.progress = false; } @@ -381,11 +379,9 @@ class HassioAddonConfig extends LitElement { await suggestAddonRestart(this, this.hass, this.supervisor, this.addon); } } catch (err: any) { - this._error = this.supervisor.localize( - "addon.failed_to_save", - "error", - extractApiErrorMessage(err) - ); + this._error = this.supervisor.localize("addon.failed_to_save", { + error: extractApiErrorMessage(err), + }); eventdata.success = false; } button.progress = false; diff --git a/hassio/src/addon-view/config/hassio-addon-network.ts b/hassio/src/addon-view/config/hassio-addon-network.ts index 0e315bbf113e..56173ab5f55e 100644 --- a/hassio/src/addon-view/config/hassio-addon-network.ts +++ b/hassio/src/addon-view/config/hassio-addon-network.ts @@ -180,11 +180,9 @@ class HassioAddonNetwork extends LitElement { await suggestAddonRestart(this, this.hass, this.supervisor, this.addon); } } catch (err: any) { - this._error = this.supervisor.localize( - "addon.failed_to_reset", - "error", - extractApiErrorMessage(err) - ); + this._error = this.supervisor.localize("addon.failed_to_reset", { + error: extractApiErrorMessage(err), + }); button.actionError(); } } @@ -220,11 +218,9 @@ class HassioAddonNetwork extends LitElement { await suggestAddonRestart(this, this.hass, this.supervisor, this.addon); } } catch (err: any) { - this._error = this.supervisor.localize( - "addon.failed_to_save", - "error", - extractApiErrorMessage(err) - ); + this._error = this.supervisor.localize("addon.failed_to_save", { + error: extractApiErrorMessage(err), + }); button.actionError(); } } diff --git a/hassio/src/addon-view/documentation/hassio-addon-documentation-tab.ts b/hassio/src/addon-view/documentation/hassio-addon-documentation-tab.ts index 98cd11b27615..905b21ea3634 100644 --- a/hassio/src/addon-view/documentation/hassio-addon-documentation-tab.ts +++ b/hassio/src/addon-view/documentation/hassio-addon-documentation-tab.ts @@ -85,8 +85,7 @@ class HassioAddonDocumentationDashboard extends LitElement { } catch (err: any) { this._error = this.supervisor.localize( "addon.documentation.get_documentation", - "error", - extractApiErrorMessage(err) + { error: extractApiErrorMessage(err) } ); } } diff --git a/hassio/src/addon-view/info/hassio-addon-info.ts b/hassio/src/addon-view/info/hassio-addon-info.ts index fee934072071..7a935518cc32 100644 --- a/hassio/src/addon-view/info/hassio-addon-info.ts +++ b/hassio/src/addon-view/info/hassio-addon-info.ts @@ -401,13 +401,14 @@ class HassioAddonInfo extends LitElement {
${this.addon.description}.
- ${this.supervisor.localize( - "addon.dashboard.visit_addon_page", - "name", - html`${this.addon.name}` - )} + >`, + })}
@@ -574,10 +575,10 @@ class HassioAddonInfo extends LitElement { ${this.supervisor.localize( "addon.dashboard.not_available_version", - "core_version_installed", - this.supervisor.core.version, - "core_version_needed", - addonStoreInfo!.homeassistant + { + core_version_installed: this.supervisor.core.version, + core_version_needed: addonStoreInfo!.homeassistant, + } )} ` @@ -750,12 +751,11 @@ class HassioAddonInfo extends LitElement { id === "stage" ? this.supervisor.localize( `addon.dashboard.capability.${id}.description`, - "icon_stable", - ``, - "icon_experimental", - ``, - "icon_deprecated", - `` + { + icon_stable: ``, + icon_experimental: ``, + icon_deprecated: ``, + } ) : this.supervisor.localize( `addon.dashboard.capability.${id}.description` @@ -817,11 +817,9 @@ class HassioAddonInfo extends LitElement { }; fireEvent(this, "hass-api-called", eventdata); } catch (err: any) { - this._error = this.supervisor.localize( - "addon.failed_to_save", - "error", - extractApiErrorMessage(err) - ); + this._error = this.supervisor.localize("addon.failed_to_save", { + error: extractApiErrorMessage(err), + }); } } @@ -839,11 +837,9 @@ class HassioAddonInfo extends LitElement { }; fireEvent(this, "hass-api-called", eventdata); } catch (err: any) { - this._error = this.supervisor.localize( - "addon.failed_to_save", - "error", - extractApiErrorMessage(err) - ); + this._error = this.supervisor.localize("addon.failed_to_save", { + error: extractApiErrorMessage(err), + }); } } @@ -861,11 +857,9 @@ class HassioAddonInfo extends LitElement { }; fireEvent(this, "hass-api-called", eventdata); } catch (err: any) { - this._error = this.supervisor.localize( - "addon.failed_to_save", - "error", - extractApiErrorMessage(err) - ); + this._error = this.supervisor.localize("addon.failed_to_save", { + error: extractApiErrorMessage(err), + }); } } @@ -883,11 +877,9 @@ class HassioAddonInfo extends LitElement { }; fireEvent(this, "hass-api-called", eventdata); } catch (err: any) { - this._error = this.supervisor.localize( - "addon.failed_to_save", - "error", - extractApiErrorMessage(err) - ); + this._error = this.supervisor.localize("addon.failed_to_save", { + error: extractApiErrorMessage(err), + }); } } @@ -905,11 +897,9 @@ class HassioAddonInfo extends LitElement { }; fireEvent(this, "hass-api-called", eventdata); } catch (err: any) { - this._error = this.supervisor.localize( - "addon.failed_to_save", - "error", - extractApiErrorMessage(err) - ); + this._error = this.supervisor.localize("addon.failed_to_save", { + error: extractApiErrorMessage(err), + }); } } diff --git a/hassio/src/addon-view/log/hassio-addon-logs.ts b/hassio/src/addon-view/log/hassio-addon-logs.ts index 2dc96453ffb1..c2cd53f962fc 100644 --- a/hassio/src/addon-view/log/hassio-addon-logs.ts +++ b/hassio/src/addon-view/log/hassio-addon-logs.ts @@ -72,11 +72,9 @@ class HassioAddonLogs extends LitElement { try { this._content = await fetchHassioAddonLogs(this.hass, this.addon.slug); } catch (err: any) { - this._error = this.supervisor.localize( - "addon.logs.get_logs", - "error", - extractApiErrorMessage(err) - ); + this._error = this.supervisor.localize("addon.logs.get_logs", { + error: extractApiErrorMessage(err), + }); } } diff --git a/hassio/src/backups/hassio-backups.ts b/hassio/src/backups/hassio-backups.ts index 80282aa7d6ad..943e6e6c646b 100644 --- a/hassio/src/backups/hassio-backups.ts +++ b/hassio/src/backups/hassio-backups.ts @@ -360,11 +360,9 @@ export class HassioBackups extends LitElement { if (this.supervisor!.info.state !== "running") { showAlertDialog(this, { title: this.supervisor!.localize("backup.could_not_create"), - text: this.supervisor!.localize( - "backup.create_blocked_not_running", - "state", - this.supervisor!.info.state - ), + text: this.supervisor!.localize("backup.create_blocked_not_running", { + state: this.supervisor!.info.state, + }), }); return; } diff --git a/hassio/src/dashboard/hassio-update.ts b/hassio/src/dashboard/hassio-update.ts index 9ef61c43f30e..3307f21427ce 100644 --- a/hassio/src/dashboard/hassio-update.ts +++ b/hassio/src/dashboard/hassio-update.ts @@ -46,11 +46,9 @@ export class HassioUpdate extends LitElement { return html`

- ${this.supervisor.localize( - "common.update_available", - "count", - updatesAvailable - )} + ${this.supervisor.localize("common.update_available", { + count: updatesAvailable, + })} 🎉

diff --git a/hassio/src/dialogs/backup/dialog-hassio-create-backup.ts b/hassio/src/dialogs/backup/dialog-hassio-create-backup.ts index da0bbdbef6e0..3e1fd79a3df1 100644 --- a/hassio/src/dialogs/backup/dialog-hassio-create-backup.ts +++ b/hassio/src/dialogs/backup/dialog-hassio-create-backup.ts @@ -89,8 +89,7 @@ class HassioCreateBackupDialog extends LitElement { ), text: this._dialogParams!.supervisor.localize( "backup.create_blocked_not_running", - "state", - this._dialogParams!.supervisor.info.state + { state: this._dialogParams!.supervisor.info.state } ), }); return; diff --git a/hassio/src/dialogs/network/dialog-hassio-network.ts b/hassio/src/dialogs/network/dialog-hassio-network.ts index f3a77f8b40a6..182efad690e0 100644 --- a/hassio/src/dialogs/network/dialog-hassio-network.ts +++ b/hassio/src/dialogs/network/dialog-hassio-network.ts @@ -145,8 +145,7 @@ export class DialogHassioNetwork ? html`

${this.supervisor.localize( "dialog.network.connected_to", - "ssid", - this._interface?.wifi?.ssid + { ssid: this._interface?.wifi?.ssid } )}

` : ""} diff --git a/hassio/src/hassio-my-redirect.ts b/hassio/src/hassio-my-redirect.ts index 71bc873eb61d..0640d4820fca 100644 --- a/hassio/src/hassio-my-redirect.ts +++ b/hassio/src/hassio-my-redirect.ts @@ -76,17 +76,15 @@ class HassioMyRedirect extends LitElement { const redirect = REDIRECTS[path]; if (!redirect) { - this._error = this.supervisor.localize( - "my.not_supported", - "link", - html` ${this.supervisor.localize("my.faq_link")} - ` - ); + `, + }); return; } diff --git a/hassio/src/system/hassio-core-info.ts b/hassio/src/system/hassio-core-info.ts index 7754728757e2..f005700b17cc 100644 --- a/hassio/src/system/hassio-core-info.ts +++ b/hassio/src/system/hassio-core-info.ts @@ -96,13 +96,11 @@ class HassioCoreInfo extends LitElement { slot="primaryAction" class="warning" @click=${this._coreRestart} - .title=${this.supervisor.localize( - "common.restart_name", - "name", - "Core" - )} + .title=${this.supervisor.localize("common.restart_name", { + name: "Core", + })} > - ${this.supervisor.localize("common.restart_name", "name", "Core")} + ${this.supervisor.localize("common.restart_name", { name: "Core" })}
@@ -122,16 +120,12 @@ class HassioCoreInfo extends LitElement { button.progress = true; const confirmed = await showConfirmationDialog(this, { - title: this.supervisor.localize( - "confirm.restart.title", - "name", - "Home Assistant Core" - ), - text: this.supervisor.localize( - "confirm.restart.text", - "name", - "Home Assistant Core" - ), + title: this.supervisor.localize("confirm.restart.title", { + name: "Home Assistant Core", + }), + text: this.supervisor.localize("confirm.restart.text", { + name: "Home Assistant Core", + }), confirmText: this.supervisor.localize("common.restart"), dismissText: this.supervisor.localize("common.cancel"), }); @@ -146,11 +140,9 @@ class HassioCoreInfo extends LitElement { } catch (err: any) { if (this.hass.connection.connected) { showAlertDialog(this, { - title: this.supervisor.localize( - "common.failed_to_restart_name", - "name", - "Home AssistantCore" - ), + title: this.supervisor.localize("common.failed_to_restart_name", { + name: "Home Assistant Core", + }), text: extractApiErrorMessage(err), }); } diff --git a/hassio/src/system/hassio-supervisor-info.ts b/hassio/src/system/hassio-supervisor-info.ts index d083bfb613ec..c025fce6cd4f 100644 --- a/hassio/src/system/hassio-supervisor-info.ts +++ b/hassio/src/system/hassio-supervisor-info.ts @@ -200,17 +200,13 @@ class HassioSupervisorInfo extends LitElement { - ${this.supervisor.localize( - "common.restart_name", - "name", - "Supervisor" - )} + ${this.supervisor.localize("common.restart_name", { + name: "Supervisor", + })}
@@ -292,16 +288,12 @@ class HassioSupervisorInfo extends LitElement { button.progress = true; const confirmed = await showConfirmationDialog(this, { - title: this.supervisor.localize( - "confirm.restart.title", - "name", - "Supervisor" - ), - text: this.supervisor.localize( - "confirm.restart.text", - "name", - "Supervisor" - ), + title: this.supervisor.localize("confirm.restart.title", { + name: "Supervisor", + }), + text: this.supervisor.localize("confirm.restart.text", { + name: "Supervisor", + }), confirmText: this.supervisor.localize("common.restart"), dismissText: this.supervisor.localize("common.cancel"), }); @@ -315,11 +307,9 @@ class HassioSupervisorInfo extends LitElement { await restartSupervisor(this.hass); } catch (err: any) { showAlertDialog(this, { - title: this.supervisor.localize( - "common.failed_to_restart_name", - "name", - "Supervisor" - ), + title: this.supervisor.localize("common.failed_to_restart_name", { + name: "Supervisor", + }), text: extractApiErrorMessage(err), }); } finally { @@ -334,8 +324,7 @@ class HassioSupervisorInfo extends LitElement { ), text: this.supervisor.localize( "system.supervisor.share_diagonstics_description", - "line_break", - html`

` + { line_break: html`

` } ), }); } diff --git a/hassio/src/system/hassio-supervisor-log.ts b/hassio/src/system/hassio-supervisor-log.ts index fec60d6d034f..a2e1d1d75e1e 100644 --- a/hassio/src/system/hassio-supervisor-log.ts +++ b/hassio/src/system/hassio-supervisor-log.ts @@ -124,13 +124,10 @@ class HassioSupervisorLog extends LitElement { this._selectedLogProvider ); } catch (err: any) { - this._error = this.supervisor.localize( - "system.log.get_logs", - "provider", - this._selectedLogProvider, - "error", - extractApiErrorMessage(err) - ); + this._error = this.supervisor.localize("system.log.get_logs", { + provider: this._selectedLogProvider, + error: extractApiErrorMessage(err), + }); } } diff --git a/src/auth/ha-auth-flow.ts b/src/auth/ha-auth-flow.ts index f23733bb79f5..e0841ebe3803 100644 --- a/src/auth/ha-auth-flow.ts +++ b/src/auth/ha-auth-flow.ts @@ -159,11 +159,9 @@ export class HaAuthFlow extends LitElement { case "error": return html` - ${this.localize( - "ui.panel.page-authorize.form.error", - "error", - this._errorMessage - )} + ${this.localize("ui.panel.page-authorize.form.error", { + error: this._errorMessage, + })}
@@ -317,15 +315,10 @@ export class HaAuthFlow extends LitElement { } private _computeStepDescription(step: DataEntryFlowStepForm) { - const resourceKey = - `ui.panel.page-authorize.form.providers.${step.handler[0]}.step.${step.step_id}.description` as const; - const args: string[] = []; - const placeholders = step.description_placeholders || {}; - Object.keys(placeholders).forEach((key) => { - args.push(key); - args.push(placeholders[key]); - }); - return this.localize(resourceKey, ...args); + return this.localize( + `ui.panel.page-authorize.form.providers.${step.handler[0]}.step.${step.step_id}.description`, + step.description_placeholders + ); } private _computeLabelCallback(step: DataEntryFlowStepForm) { diff --git a/src/common/structs/handle-errors.ts b/src/common/structs/handle-errors.ts index 96c82081c565..ad5cb080d94f 100644 --- a/src/common/structs/handle-errors.ts +++ b/src/common/structs/handle-errors.ts @@ -13,45 +13,33 @@ export const handleStructError = ( for (const failure of err.failures()) { if (failure.value === undefined) { errors.push( - hass.localize( - "ui.errors.config.key_missing", - "key", - failure.path.join(".") - ) + hass.localize("ui.errors.config.key_missing", { + key: failure.path.join("."), + }) ); } else if (failure.type === "never") { warnings.push( - hass.localize( - "ui.errors.config.key_not_expected", - "key", - failure.path.join(".") - ) + hass.localize("ui.errors.config.key_not_expected", { + key: failure.path.join("."), + }) ); } else if (failure.type === "union") { continue; } else if (failure.type === "enums") { warnings.push( - hass.localize( - "ui.errors.config.key_wrong_type", - "key", - failure.path.join("."), - "type_correct", - failure.message.replace("Expected ", "").split(", ")[0], - "type_wrong", - JSON.stringify(failure.value) - ) + hass.localize("ui.errors.config.key_wrong_type", { + key: failure.path.join("."), + type_correct: failure.message.replace("Expected ", "").split(", ")[0], + type_wrong: JSON.stringify(failure.value), + }) ); } else { warnings.push( - hass.localize( - "ui.errors.config.key_wrong_type", - "key", - failure.path.join("."), - "type_correct", - failure.refinement || failure.type, - "type_wrong", - JSON.stringify(failure.value) - ) + hass.localize("ui.errors.config.key_wrong_type", { + key: failure.path.join("."), + type_correct: failure.refinement || failure.type, + type_wrong: JSON.stringify(failure.value), + }) ); } } diff --git a/src/components/ha-button-related-filter-menu.ts b/src/components/ha-button-related-filter-menu.ts index c83bdcdd6cb8..0225f77cab99 100644 --- a/src/components/ha-button-related-filter-menu.ts +++ b/src/components/ha-button-related-filter-menu.ts @@ -126,8 +126,11 @@ export class HaRelatedFilterButtonMenu extends LitElement { } const filter = this.hass.localize( "ui.components.related-filter-menu.filtered_by_entity", - "entity_name", - computeStateName((ev.currentTarget as any).comboBox.selectedItem) + { + entity_name: computeStateName( + (ev.currentTarget as any).comboBox.selectedItem + ), + } ); const items = await findRelated(this.hass, "entity", entityId); fireEvent(this, "related-changed", { @@ -146,11 +149,12 @@ export class HaRelatedFilterButtonMenu extends LitElement { } const filter = this.hass.localize( "ui.components.related-filter-menu.filtered_by_device", - "device_name", - computeDeviceName( - (ev.currentTarget as any).comboBox.selectedItem, - this.hass - ) + { + device_name: computeDeviceName( + (ev.currentTarget as any).comboBox.selectedItem, + this.hass + ), + } ); const items = await findRelated(this.hass, "device", deviceId); @@ -170,8 +174,7 @@ export class HaRelatedFilterButtonMenu extends LitElement { } const filter = this.hass.localize( "ui.components.related-filter-menu.filtered_by_area", - "area_name", - (ev.currentTarget as any).comboBox.selectedItem.name + { area_name: (ev.currentTarget as any).comboBox.selectedItem.name } ); const items = await findRelated(this.hass, "area", areaId); fireEvent(this, "related-changed", { diff --git a/src/components/media-player/ha-media-player-browse.ts b/src/components/media-player/ha-media-player-browse.ts index e5c895e74268..cc755e688771 100644 --- a/src/components/media-player/ha-media-player-browse.ts +++ b/src/components/media-player/ha-media-player-browse.ts @@ -798,10 +798,8 @@ export class HaMediaPlayerBrowse extends LitElement {

${this.hass.localize("ui.components.media-browser.no_media_folder")}
- ${this.hass.localize( - "ui.components.media-browser.setup_local_help", - "documentation", - html`${this.hass.localize( "ui.components.media-browser.documentation" )}` - )} + >`, + })}
${this.hass.localize("ui.components.media-browser.local_media_files")}

diff --git a/src/data/application_credential.ts b/src/data/application_credential.ts index 65f9d25a7da7..4b4cebdac98b 100644 --- a/src/data/application_credential.ts +++ b/src/data/application_credential.ts @@ -1,7 +1,7 @@ import { HomeAssistant } from "../types"; export interface ApplicationCredentialsDomainConfig { - description_placeholders: string; + description_placeholders: Record; } export interface ApplicationCredentialsConfig { diff --git a/src/data/device_automation.ts b/src/data/device_automation.ts index 5dc8e2879204..b32355e833ed 100644 --- a/src/data/device_automation.ts +++ b/src/data/device_automation.ts @@ -201,14 +201,14 @@ export const localizeDeviceAutomationAction = ( ): string => hass.localize( `component.${action.domain}.device_automation.action_type.${action.type}`, - "entity_name", - getEntityName(hass, entityRegistry, action.entity_id), - "subtype", - action.subtype - ? hass.localize( - `component.${action.domain}.device_automation.action_subtype.${action.subtype}` - ) || action.subtype - : "" + { + entity_name: getEntityName(hass, entityRegistry, action.entity_id), + subtype: action.subtype + ? hass.localize( + `component.${action.domain}.device_automation.action_subtype.${action.subtype}` + ) || action.subtype + : "", + } ) || (action.subtype ? `"${action.subtype}" ${action.type}` : action.type!); export const localizeDeviceAutomationCondition = ( @@ -218,14 +218,14 @@ export const localizeDeviceAutomationCondition = ( ): string => hass.localize( `component.${condition.domain}.device_automation.condition_type.${condition.type}`, - "entity_name", - getEntityName(hass, entityRegistry, condition.entity_id), - "subtype", - condition.subtype - ? hass.localize( - `component.${condition.domain}.device_automation.condition_subtype.${condition.subtype}` - ) || condition.subtype - : "" + { + entity_name: getEntityName(hass, entityRegistry, condition.entity_id), + subtype: condition.subtype + ? hass.localize( + `component.${condition.domain}.device_automation.condition_subtype.${condition.subtype}` + ) || condition.subtype + : "", + } ) || (condition.subtype ? `"${condition.subtype}" ${condition.type}` @@ -238,14 +238,14 @@ export const localizeDeviceAutomationTrigger = ( ): string => hass.localize( `component.${trigger.domain}.device_automation.trigger_type.${trigger.type}`, - "entity_name", - getEntityName(hass, entityRegistry, trigger.entity_id), - "subtype", - trigger.subtype - ? hass.localize( - `component.${trigger.domain}.device_automation.trigger_subtype.${trigger.subtype}` - ) || trigger.subtype - : "" + { + entity_name: getEntityName(hass, entityRegistry, trigger.entity_id), + subtype: trigger.subtype + ? hass.localize( + `component.${trigger.domain}.device_automation.trigger_subtype.${trigger.subtype}` + ) || trigger.subtype + : "", + } ) || (trigger.subtype ? `"${trigger.subtype}" ${trigger.type}` : trigger.type!); diff --git a/src/data/device_registry.ts b/src/data/device_registry.ts index 37685de00792..0919b4c1acb1 100644 --- a/src/data/device_registry.ts +++ b/src/data/device_registry.ts @@ -64,13 +64,11 @@ export const computeDeviceName = ( device.name_by_user || device.name || (entities && fallbackDeviceName(hass, entities)) || - hass.localize( - "ui.panel.config.devices.unnamed_device", - "type", - hass.localize( + hass.localize("ui.panel.config.devices.unnamed_device", { + type: hass.localize( `ui.panel.config.devices.type.${device.entry_type || "device"}` - ) - ); + ), + }); export const devicesInArea = (devices: DeviceRegistryEntry[], areaId: string) => devices.filter((device) => device.area_id === areaId); diff --git a/src/data/logbook.ts b/src/data/logbook.ts index 8534d548ceb8..703ca6969dd9 100644 --- a/src/data/logbook.ts +++ b/src/data/logbook.ts @@ -194,7 +194,7 @@ export const localizeStateMessage = ( if (state === "home") { return localize(`${LOGBOOK_LOCALIZE_PATH}.was_at_home`); } - return localize(`${LOGBOOK_LOCALIZE_PATH}.was_at_state`, "state", state); + return localize(`${LOGBOOK_LOCALIZE_PATH}.was_at_state`, { state }); case "sun": return state === "above_horizon" @@ -382,11 +382,9 @@ export const localizeStateMessage = ( return localize(`${LOGBOOK_LOCALIZE_PATH}.became_unavailable`); } - return hass.localize( - `${LOGBOOK_LOCALIZE_PATH}.changed_to_state`, - "state", - stateObj ? hass.formatEntityState(stateObj, state) : state - ); + return hass.localize(`${LOGBOOK_LOCALIZE_PATH}.changed_to_state`, { + state: stateObj ? hass.formatEntityState(stateObj, state) : state, + }); }; export const filterLogbookCompatibleEntities: HaEntityPickerEntityFilterFunc = ( diff --git a/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts b/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts index afd1c6f159c2..7ed96ec06197 100644 --- a/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts +++ b/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts @@ -56,9 +56,12 @@ class DialogConfigEntrySystemOptions extends LitElement { @closed=${this.closeDialog} .heading=${this.hass.localize( "ui.dialogs.config_entry_system_options.title", - "integration", - this.hass.localize(`component.${this._params.entry.domain}.title`) || - this._params.entry.domain + { + integration: + this.hass.localize( + `component.${this._params.entry.domain}.title` + ) || this._params.entry.domain, + } )} > ${this._error ? html`
${this._error}
` : ""} @@ -71,10 +74,12 @@ class DialogConfigEntrySystemOptions extends LitElement {

${this.hass.localize( "ui.dialogs.config_entry_system_options.enable_new_entities_description", - "integration", - this.hass.localize( - `component.${this._params.entry.domain}.title` - ) || this._params.entry.domain + { + integration: + this.hass.localize( + `component.${this._params.entry.domain}.title` + ) || this._params.entry.domain, + } )}

`} .dir=${computeRTLDirection(this.hass)} @@ -96,10 +101,12 @@ class DialogConfigEntrySystemOptions extends LitElement {

${this.hass.localize( "ui.dialogs.config_entry_system_options.enable_polling_description", - "integration", - this.hass.localize( - `component.${this._params.entry.domain}.title` - ) || this._params.entry.domain + { + integration: + this.hass.localize( + `component.${this._params.entry.domain}.title` + ) || this._params.entry.domain, + } )}

`} .dir=${computeRTLDirection(this.hass)} diff --git a/src/dialogs/config-flow/show-dialog-config-flow.ts b/src/dialogs/config-flow/show-dialog-config-flow.ts index 23c37f1797b2..9ccc58184015 100644 --- a/src/dialogs/config-flow/show-dialog-config-flow.ts +++ b/src/dialogs/config-flow/show-dialog-config-flow.ts @@ -174,8 +174,7 @@ export const showConfigFlowDialog = (

${hass.localize( "ui.panel.config.integrations.config_flow.created_config", - "name", - step.title + { name: step.title } )}

`; diff --git a/src/dialogs/config-flow/step-flow-create-entry.ts b/src/dialogs/config-flow/step-flow-create-entry.ts index 1ceb034b7a0a..f7e15836d76b 100644 --- a/src/dialogs/config-flow/step-flow-create-entry.ts +++ b/src/dialogs/config-flow/step-flow-create-entry.ts @@ -98,8 +98,7 @@ class StepFlowCreateEntry extends LitElement { showAlertDialog(this, { text: this.hass.localize( "ui.panel.config.integrations.config_flow.error_saving_area", - "error", - err.message + { error: err.message } ), }); picker.value = null; diff --git a/src/dialogs/notifications/configurator-notification-item.ts b/src/dialogs/notifications/configurator-notification-item.ts index 306b0f40beed..ae69269952d1 100644 --- a/src/dialogs/notifications/configurator-notification-item.ts +++ b/src/dialogs/notifications/configurator-notification-item.ts @@ -25,11 +25,9 @@ export class HuiConfiguratorNotificationItem extends LitElement {
- ${this.hass.localize( - "ui.notification_drawer.click_to_configure", - "entity", - this.notification.attributes.friendly_name - )} + ${this.hass.localize("ui.notification_drawer.click_to_configure", { + entity: this.notification.attributes.friendly_name, + })}
diff --git a/src/dialogs/quick-bar/ha-quick-bar.ts b/src/dialogs/quick-bar/ha-quick-bar.ts index 5db6f06289e6..4daf94a0f88e 100644 --- a/src/dialogs/quick-bar/ha-quick-bar.ts +++ b/src/dialogs/quick-bar/ha-quick-bar.ts @@ -525,11 +525,9 @@ export class QuickBar extends LitElement { const commands = reloadableDomains.map((domain) => ({ primaryText: this.hass.localize(`ui.dialogs.quick-bar.commands.reload.${domain}`) || - this.hass.localize( - "ui.dialogs.quick-bar.commands.reload.reload", - "domain", - domainToName(localize, domain) - ), + this.hass.localize("ui.dialogs.quick-bar.commands.reload.reload", { + domain: domainToName(localize, domain), + }), action: () => this.hass.callService(domain, "reload"), iconPath: mdiReload, categoryText: this.hass.localize( @@ -590,10 +588,11 @@ export class QuickBar extends LitElement { const item = { primaryText: this.hass.localize( "ui.dialogs.quick-bar.commands.server_control.perform_action", - "action", - this.hass.localize( - `ui.dialogs.quick-bar.commands.server_control.${action}` - ) + { + action: this.hass.localize( + `ui.dialogs.quick-bar.commands.server_control.${action}` + ), + } ), iconPath: mdiServerNetwork, categoryText: this.hass.localize( diff --git a/src/layouts/hass-tabs-subpage-data-table.ts b/src/layouts/hass-tabs-subpage-data-table.ts index 5efadf11017b..f891f6b1f9b3 100644 --- a/src/layouts/hass-tabs-subpage-data-table.ts +++ b/src/layouts/hass-tabs-subpage-data-table.ts @@ -147,11 +147,9 @@ export class HaTabsSubpageDataTable extends LitElement { protected render(): TemplateResult { const hiddenLabel = this.numHidden ? this.hiddenLabel || - this.hass.localize( - "ui.components.data-table.hidden", - "number", - this.numHidden - ) || + this.hass.localize("ui.components.data-table.hidden", { + number: this.numHidden, + }) || this.numHidden : undefined; diff --git a/src/panels/config/application_credentials/ha-config-application-credentials.ts b/src/panels/config/application_credentials/ha-config-application-credentials.ts index ec1b97dba308..43a4a4b525e3 100644 --- a/src/panels/config/application_credentials/ha-config-application-credentials.ts +++ b/src/panels/config/application_credentials/ha-config-application-credentials.ts @@ -120,8 +120,7 @@ export class HaConfigApplicationCredentials extends LitElement {

${this.hass.localize( "ui.panel.config.application_credentials.picker.selected", - "number", - this._selected.length + { number: this._selected.length } )}

@@ -178,8 +177,7 @@ export class HaConfigApplicationCredentials extends LitElement { showConfirmationDialog(this, { title: this.hass.localize( `ui.panel.config.application_credentials.picker.remove_selected.confirm_title`, - "number", - this._selected.length + { number: this._selected.length } ), text: this.hass.localize( "ui.panel.config.application_credentials.picker.remove_selected.confirm_text" diff --git a/src/panels/config/areas/ha-config-areas-dashboard.ts b/src/panels/config/areas/ha-config-areas-dashboard.ts index 5b03220dec3a..3623d585571b 100644 --- a/src/panels/config/areas/ha-config-areas-dashboard.ts +++ b/src/panels/config/areas/ha-config-areas-dashboard.ts @@ -1,9 +1,10 @@ import { mdiHelpCircle, mdiPlus } from "@mdi/js"; import { UnsubscribeFunc } from "home-assistant-js-websocket"; -import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; +import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit"; import { customElement, property, state } from "lit/decorators"; import { styleMap } from "lit/directives/style-map"; import memoizeOne from "memoize-one"; +import { formatListWithAnds } from "../../../common/string/format-list"; import "../../../components/ha-fab"; import "../../../components/ha-icon-button"; import "../../../components/ha-svg-icon"; @@ -135,36 +136,26 @@ export class HaConfigAreasDashboard extends SubscribeMixin(LitElement) {

${area.name}

- ${area.devices - ? html` - ${this.hass.localize( + ${formatListWithAnds( + this.hass.locale, + [ + area.devices && + this.hass.localize( "ui.panel.config.integrations.config_entry.devices", - "count", - area.devices - )}${area.services ? "," : ""} - ` - : ""} - ${area.services - ? html` - ${this.hass.localize( + { count: area.devices } + ), + area.services && + this.hass.localize( "ui.panel.config.integrations.config_entry.services", - "count", - area.services - )} - ` - : ""} - ${(area.devices || area.services) && area.entities - ? this.hass.localize("ui.common.and") - : ""} - ${area.entities - ? html` - ${this.hass.localize( + { count: area.services } + ), + area.entities && + this.hass.localize( "ui.panel.config.integrations.config_entry.entities", - "count", - area.entities - )} - ` - : ""} + { count: area.entities } + ), + ].filter((v): v is string => Boolean(v)) + )}
1) { str += this.hass.localize( "ui.panel.config.automation.editor.actions.type.choose.option_description_additional", - "numberOfAdditionalConditions", - option.conditions.length - 1 + { numberOfAdditionalConditions: option.conditions.length - 1 } ); } return str; @@ -121,8 +120,7 @@ export class HaChooseAction extends LitElement implements ActionElement {

${this.hass.localize( "ui.panel.config.automation.editor.actions.type.choose.option", - "number", - idx + 1 + { number: idx + 1 } )}: ${this._getDescription(option, idx)}

diff --git a/src/panels/config/automation/condition/ha-automation-condition-editor.ts b/src/panels/config/automation/condition/ha-automation-condition-editor.ts index eb4558569e9a..f60132ae5915 100644 --- a/src/panels/config/automation/condition/ha-automation-condition-editor.ts +++ b/src/panels/config/automation/condition/ha-automation-condition-editor.ts @@ -49,8 +49,7 @@ export default class HaAutomationConditionEditor extends LitElement { ? html` ${this.hass.localize( "ui.panel.config.automation.editor.conditions.unsupported_condition", - "condition", - condition.condition + { condition: condition.condition } )} ` : ""} diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index 50302c280159..f3b8b0690063 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -543,8 +543,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { ) : this.hass.localize( "ui.panel.config.automation.editor.load_error_unknown", - "err_no", - err.status_code + { err_no: err.status_code } ), }); history.back(); diff --git a/src/panels/config/automation/ha-automation-picker.ts b/src/panels/config/automation/ha-automation-picker.ts index c608b2008655..eba138fc231e 100644 --- a/src/panels/config/automation/ha-automation-picker.ts +++ b/src/panels/config/automation/ha-automation-picker.ts @@ -352,10 +352,12 @@ class HaAutomationPicker extends LitElement { this._activeFilters = [ this.hass.localize( "ui.panel.config.automation.picker.filtered_by_blueprint", - "name", - !blueprintMeta || "error" in blueprintMeta - ? blueprint - : blueprintMeta.metadata.name || blueprint + { + name: + !blueprintMeta || "error" in blueprintMeta + ? blueprint + : blueprintMeta.metadata.name || blueprint, + } ), ]; } @@ -431,8 +433,7 @@ class HaAutomationPicker extends LitElement { ) : this.hass.localize( "ui.panel.config.automation.editor.load_error_unknown", - "err_no", - err.status_code + { err_no: err.status_code } ), }); } @@ -457,8 +458,7 @@ class HaAutomationPicker extends LitElement { await showAlertDialog(this, { text: this.hass.localize( "ui.panel.config.automation.editor.load_error_unknown", - "err_no", - err.status_code + { err_no: err.status_code } ), }); } diff --git a/src/panels/config/automation/trigger/ha-automation-trigger-row.ts b/src/panels/config/automation/trigger/ha-automation-trigger-row.ts index cbc1e7bff34f..90ec31331ace 100644 --- a/src/panels/config/automation/trigger/ha-automation-trigger-row.ts +++ b/src/panels/config/automation/trigger/ha-automation-trigger-row.ts @@ -324,8 +324,7 @@ export default class HaAutomationTriggerRow extends LitElement { ? html` ${this.hass.localize( "ui.panel.config.automation.editor.triggers.unsupported_platform", - "platform", - this.trigger.platform + { platform: this.trigger.platform } )} ` : ""} diff --git a/src/panels/config/blueprint/dialog-import-blueprint.ts b/src/panels/config/blueprint/dialog-import-blueprint.ts index 779427086660..0e871fc19ad7 100644 --- a/src/panels/config/blueprint/dialog-import-blueprint.ts +++ b/src/panels/config/blueprint/dialog-import-blueprint.ts @@ -67,10 +67,10 @@ class DialogImportBlueprint extends LitElement { ${this._result ? html`${this.hass.localize( "ui.panel.config.blueprint.add.import_header", - "name", - html`${this._result.blueprint.metadata.name}`, - "domain", - this._result.blueprint.metadata.domain + { + name: html`${this._result.blueprint.metadata.name}`, + domain: this._result.blueprint.metadata.domain, + } )}
- ${this.hass.localize( - "ui.panel.config.cloud.account.tts.info", - "service", - '"tts.cloud_say"' - )} + ${this.hass.localize("ui.panel.config.cloud.account.tts.info", { + service: '"tts.cloud_say"', + })}

diff --git a/src/panels/config/core/ha-config-system-navigation.ts b/src/panels/config/core/ha-config-system-navigation.ts index ade0cf81a84a..821d3479b106 100644 --- a/src/panels/config/core/ha-config-system-navigation.ts +++ b/src/panels/config/core/ha-config-system-navigation.ts @@ -50,57 +50,39 @@ class HaConfigSystemNavigation extends LitElement { const pages = configSections.general .filter((page) => canShowPage(this.hass, page)) .map((page) => { - let description = ""; - - switch (page.translationKey) { - case "backup": - description = this._latestBackupDate - ? this.hass.localize( - "ui.panel.config.backup.description", - "relative_time", - relativeTime( + const description = + page.translationKey === "backup" + ? this._latestBackupDate + ? this.hass.localize("ui.panel.config.backup.description", { + relative_time: relativeTime( new Date(this._latestBackupDate), this.hass.locale - ) - ) + ), + }) : this.hass.localize( "ui.panel.config.backup.description_no_backup" - ); - break; - case "network": - description = this.hass.localize( - "ui.panel.config.network.description", - "state", - this._externalAccess - ? this.hass.localize("ui.panel.config.network.enabled") - : this.hass.localize("ui.panel.config.network.disabled") - ); - break; - case "storage": - description = this._storageInfo - ? this.hass.localize( - "ui.panel.config.storage.description", - "percent_used", - `${Math.round( + ) + : page.translationKey === "network" + ? this.hass.localize("ui.panel.config.network.description", { + state: this._externalAccess + ? this.hass.localize("ui.panel.config.network.enabled") + : this.hass.localize("ui.panel.config.network.disabled"), + }) + : page.translationKey === "storage" + ? this._storageInfo + ? this.hass.localize("ui.panel.config.storage.description", { + percent_used: `${Math.round( (this._storageInfo.used / this._storageInfo.total) * 100 )}${blankBeforePercent(this.hass.locale)}%`, - "free_space", - `${this._storageInfo.free} GB` - ) - : ""; - break; - case "hardware": - description = - this._boardName || - this.hass.localize("ui.panel.config.hardware.description"); - break; - - default: - description = this.hass.localize( - `ui.panel.config.${page.translationKey}.description` - ); - break; - } + free_space: `${this._storageInfo.free} GB`, + }) + : "" + : page.translationKey === "hardware" + ? this._boardName || + this.hass.localize("ui.panel.config.hardware.description") + : this.hass.localize( + `ui.panel.config.${page.translationKey}.description` + ); return { ...page, diff --git a/src/panels/config/dashboard/ha-config-dashboard.ts b/src/panels/config/dashboard/ha-config-dashboard.ts index bbe63dcbbb95..241043049c90 100644 --- a/src/panels/config/dashboard/ha-config-dashboard.ts +++ b/src/panels/config/dashboard/ha-config-dashboard.ts @@ -55,46 +55,40 @@ const randomTip = (hass: HomeAssistant, narrow: boolean) => { const weighted: string[] = []; let tips = [ { - content: hass.localize( - "ui.panel.config.tips.join", - "forums", - html`Forums`, - "twitter", - html`Twitter`, - "discord", - html`Chat`, - "blog", - html`Blog`, - "newsletter", - html`Newsletter - ` - ), + `, + }), weight: 2, narrow: true, }, diff --git a/src/panels/config/devices/device-detail/ha-device-entities-card.ts b/src/panels/config/devices/device-detail/ha-device-entities-card.ts index 4c1681d88500..4876f8c4f06e 100644 --- a/src/panels/config/devices/device-detail/ha-device-entities-card.ts +++ b/src/panels/config/devices/device-detail/ha-device-entities-card.ts @@ -103,8 +103,7 @@ export class HaDeviceEntitiesCard extends LitElement { ` diff --git a/src/panels/config/devices/device-detail/ha-device-info-card.ts b/src/panels/config/devices/device-detail/ha-device-info-card.ts index 219031a40389..9443fbc56330 100644 --- a/src/panels/config/devices/device-detail/ha-device-info-card.ts +++ b/src/panels/config/devices/device-detail/ha-device-info-card.ts @@ -26,15 +26,13 @@ export class HaDeviceCard extends LitElement { return html`
${this.device.model @@ -45,8 +43,7 @@ export class HaDeviceCard extends LitElement {
${this.hass.localize( "ui.panel.config.integrations.config_entry.manuf", - "manufacturer", - this.device.manufacturer + { manufacturer: this.device.manufacturer } )}
` @@ -79,8 +76,7 @@ export class HaDeviceCard extends LitElement { ? "version" : "firmware" }`, - "version", - this.device.sw_version + { version: this.device.sw_version } )}
` @@ -90,8 +86,7 @@ export class HaDeviceCard extends LitElement {
${this.hass.localize( "ui.panel.config.integrations.config_entry.hardware", - "version", - this.device.hw_version + { version: this.device.hw_version } )}
` diff --git a/src/panels/config/devices/device-detail/ha-device-via-devices-card.ts b/src/panels/config/devices/device-detail/ha-device-via-devices-card.ts index fd75189514bb..aa664ce9e0d0 100644 --- a/src/panels/config/devices/device-detail/ha-device-via-devices-card.ts +++ b/src/panels/config/devices/device-detail/ha-device-via-devices-card.ts @@ -69,8 +69,7 @@ export class HaDeviceViaDevicesCard extends LitElement { ` diff --git a/src/panels/config/devices/device-detail/integration-elements/mqtt/dialog-mqtt-device-debug-info.ts b/src/panels/config/devices/device-detail/integration-elements/mqtt/dialog-mqtt-device-debug-info.ts index d3d15a4a28f5..d3e5b38236a0 100644 --- a/src/panels/config/devices/device-detail/integration-elements/mqtt/dialog-mqtt-device-debug-info.ts +++ b/src/panels/config/devices/device-detail/integration-elements/mqtt/dialog-mqtt-device-debug-info.ts @@ -59,8 +59,7 @@ class DialogMQTTDeviceDebugInfo extends LitElement { @closed=${this._close} .heading=${this.hass!.localize( "ui.dialogs.mqtt_device_debug_info.title", - "device", - computeDeviceName(this._params.device, this.hass) + { device: computeDeviceName(this._params.device, this.hass) } )} >

@@ -179,11 +178,9 @@ class DialogMQTTDeviceDebugInfo extends LitElement { .subscribedTopic=${topic.topic} .summary=${this.hass!.localize( "ui.dialogs.mqtt_device_debug_info.recent_messages", - "n", - topic.messages.length + { n: topic.messages.length } )} - > - + > ` )} @@ -203,11 +200,9 @@ class DialogMQTTDeviceDebugInfo extends LitElement { .subscribedTopic=${topic.topic} .summary=${this.hass!.localize( "ui.dialogs.mqtt_device_debug_info.recent_tx_messages", - "n", - topic.messages.length + { n: topic.messages.length } )} - > - + > ` )} diff --git a/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-info-zwave_js.ts b/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-info-zwave_js.ts index 64d9d0145b42..22d371bcc0f4 100644 --- a/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-info-zwave_js.ts +++ b/src/panels/config/devices/device-detail/integration-elements/zwave_js/ha-device-info-zwave_js.ts @@ -127,8 +127,7 @@ export class HaDeviceInfoZWaveJS extends SubscribeMixin(LitElement) { ${this._node.zwave_plus_version ? this.hass.localize( "ui.panel.config.zwave_js.device_info.zwave_plus_version", - "version", - this._node.zwave_plus_version + { version: this._node.zwave_plus_version } ) : this.hass.localize("ui.common.no")}

diff --git a/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts b/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts index 204d115b2461..13b5c0ab98d1 100644 --- a/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts +++ b/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts @@ -90,28 +90,29 @@ class DialogDeviceRegistryDetail extends LitElement {
${this.hass.localize( "ui.dialogs.device-registry-detail.enabled_label", - "type", - this.hass.localize( - `ui.dialogs.device-registry-detail.type.${ - device.entry_type || "device" - }` - ) + { + type: this.hass.localize( + `ui.dialogs.device-registry-detail.type.${ + device.entry_type || "device" + }` + ), + } )}
${this._disabledBy && this._disabledBy !== "user" ? this.hass.localize( "ui.dialogs.device-registry-detail.enabled_cause", - "type", - this.hass.localize( - `ui.dialogs.device-registry-detail.type.${ - device.entry_type || "device" - }` - ), - "cause", - this.hass.localize( - `config_entry.disabled_by.${this._disabledBy}` - ) + { + type: this.hass.localize( + `ui.dialogs.device-registry-detail.type.${ + device.entry_type || "device" + }` + ), + cause: this.hass.localize( + `config_entry.disabled_by.${this._disabledBy}` + ), + } ) : ""} ${this.hass.localize( diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts index c231c7310df5..ef55e03e9a7f 100644 --- a/src/panels/config/devices/ha-config-device-page.ts +++ b/src/panels/config/devices/ha-config-device-page.ts @@ -386,17 +386,14 @@ export class HaConfigDevicePage extends LitElement { if (device.disabled_by) { deviceInfo.push(html` - ${this.hass.localize( - "ui.panel.config.devices.enabled_cause", - "type", - this.hass.localize( + ${this.hass.localize("ui.panel.config.devices.enabled_cause", { + type: this.hass.localize( `ui.panel.config.devices.type.${device.entry_type || "device"}` ), - "cause", - this.hass.localize( + cause: this.hass.localize( `ui.panel.config.devices.disabled_by.${device.disabled_by}` - ) - )} + ), + })} ${device.disabled_by === "user" ? html` @@ -425,12 +422,13 @@ export class HaConfigDevicePage extends LitElement { .label=${device.disabled_by ? this.hass.localize( "ui.panel.config.devices.automation.create_disable", - "type", - this.hass.localize( - `ui.panel.config.devices.type.${ - device.entry_type || "device" - }` - ) + { + type: this.hass.localize( + `ui.panel.config.devices.type.${ + device.entry_type || "device" + }` + ), + } ) : this.hass.localize( "ui.panel.config.devices.automation.create", @@ -485,19 +483,16 @@ export class HaConfigDevicePage extends LitElement { ` : html`
- ${this.hass.localize( - "ui.panel.config.devices.add_prompt", - "name", - this.hass.localize( + ${this.hass.localize("ui.panel.config.devices.add_prompt", { + name: this.hass.localize( "ui.panel.config.devices.automation.automations" ), - "type", - this.hass.localize( + type: this.hass.localize( `ui.panel.config.devices.type.${ device.entry_type || "device" }` - ) - )} + ), + })}
`} @@ -516,25 +511,18 @@ export class HaConfigDevicePage extends LitElement { @@ -582,16 +570,16 @@ export class HaConfigDevicePage extends LitElement {
${this.hass.localize( "ui.panel.config.devices.add_prompt", - "name", - this.hass.localize( - "ui.panel.config.devices.scene.scenes" - ), - "type", - this.hass.localize( - `ui.panel.config.devices.type.${ - device.entry_type || "device" - }` - ) + { + name: this.hass.localize( + "ui.panel.config.devices.scene.scenes" + ), + type: this.hass.localize( + `ui.panel.config.devices.type.${ + device.entry_type || "device" + }` + ), + } )}
`} @@ -609,25 +597,18 @@ export class HaConfigDevicePage extends LitElement { @@ -660,19 +641,16 @@ export class HaConfigDevicePage extends LitElement { ` : html`
- ${this.hass.localize( - "ui.panel.config.devices.add_prompt", - "name", - this.hass.localize( + ${this.hass.localize("ui.panel.config.devices.add_prompt", { + name: this.hass.localize( "ui.panel.config.devices.script.scripts" ), - "type", - this.hass.localize( + type: this.hass.localize( `ui.panel.config.devices.type.${ device.entry_type || "device" }` - ) - )} + ), + })}
`} @@ -685,15 +663,12 @@ export class HaConfigDevicePage extends LitElement { .narrow=${this.narrow} .header=${deviceName} > - - +
` @@ -1263,8 +1237,7 @@ export class HaConfigDevicePage extends LitElement { (await showConfirmationDialog(this, { title: this.hass.localize( "ui.panel.config.devices.confirm_disable_config_entry", - "entry_name", - config_entry.title + { entry_name: config_entry.title } ), confirmText: this.hass.localize("ui.common.yes"), dismissText: this.hass.localize("ui.common.no"), diff --git a/src/panels/config/devices/ha-config-devices-dashboard.ts b/src/panels/config/devices/ha-config-devices-dashboard.ts index 0526d048d11f..cce6b2e9675f 100644 --- a/src/panels/config/devices/ha-config-devices-dashboard.ts +++ b/src/panels/config/devices/ha-config-devices-dashboard.ts @@ -470,8 +470,7 @@ export class HaConfigDeviceDashboard extends LitElement { )} .hiddenLabel=${this.hass.localize( "ui.panel.config.devices.picker.filter.hidden_devices", - "number", - this._numHiddenDevices + { number: this._numHiddenDevices } )} .columns=${this._columns(this.narrow, this._showDisabled)} .data=${devicesOutput} diff --git a/src/panels/config/entities/editor-tabs/settings/entity-settings-helper-tab.ts b/src/panels/config/entities/editor-tabs/settings/entity-settings-helper-tab.ts index dd42f8b34e55..422fde1665fd 100644 --- a/src/panels/config/entities/editor-tabs/settings/entity-settings-helper-tab.ts +++ b/src/panels/config/entities/editor-tabs/settings/entity-settings-helper-tab.ts @@ -82,8 +82,7 @@ export class EntityRegistrySettingsHelper extends LitElement { ${!this._componentLoaded ? this.hass.localize( "ui.dialogs.helper_settings.platform_not_loaded", - "platform", - this.entry.platform + { platform: this.entry.platform } ) : this._item === null ? this.hass.localize("ui.dialogs.helper_settings.yaml_not_editable") diff --git a/src/panels/config/entities/entity-registry-settings-editor.ts b/src/panels/config/entities/entity-registry-settings-editor.ts index 840e3101145c..ef94f8a33b1a 100644 --- a/src/panels/config/entities/entity-registry-settings-editor.ts +++ b/src/panels/config/entities/entity-registry-settings-editor.ts @@ -776,21 +776,23 @@ export class EntityRegistrySettingsEditor extends LitElement { ${this.hass.localize( "ui.dialogs.entity_registry.editor.configure_state", - "integration", - domainToName( - this.hass.localize, - this.helperConfigEntry.domain - ) + { + integration: domainToName( + this.hass.localize, + this.helperConfigEntry.domain + ), + } )} ${this.hass.localize( "ui.dialogs.entity_registry.editor.configure_state_secondary", - "integration", - domainToName( - this.hass.localize, - this.helperConfigEntry.domain - ) + { + integration: domainToName( + this.hass.localize, + this.helperConfigEntry.domain + ), + } )} @@ -828,10 +830,11 @@ export class EntityRegistrySettingsEditor extends LitElement { ? html`${this.hass.localize( "ui.dialogs.entity_registry.editor.enabled_cause", - "cause", - this.hass.localize( - `config_entry.disabled_by.${this._disabledBy!}` - ) + { + cause: this.hass.localize( + `config_entry.disabled_by.${this._disabledBy!}` + ), + } )}` : ""} @@ -862,8 +865,11 @@ export class EntityRegistrySettingsEditor extends LitElement { ? html`${this.hass.localize( "ui.dialogs.entity_registry.editor.hidden_cause", - "cause", - this.hass.localize(`config_entry.hidden_by.${this._hiddenBy!}`) + { + cause: this.hass.localize( + `config_entry.hidden_by.${this._hiddenBy!}` + ), + } )}` : ""} @@ -1036,8 +1042,7 @@ export class EntityRegistrySettingsEditor extends LitElement { showAlertDialog(this, { text: this.hass.localize( "ui.dialogs.entity_registry.editor.enabled_delay_confirm", - "delay", - result.reload_delay + { delay: result.reload_delay } ), }); } diff --git a/src/panels/config/entities/entity-registry-settings.ts b/src/panels/config/entities/entity-registry-settings.ts index f8ed35716754..816363e617fd 100644 --- a/src/panels/config/entities/entity-registry-settings.ts +++ b/src/panels/config/entities/entity-registry-settings.ts @@ -182,8 +182,7 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) { showAlertDialog(this, { text: this.hass.localize( "ui.dialogs.entity_registry.editor.enabled_delay_confirm", - "delay", - result.reload_delay + { delay: result.reload_delay } ), }); } diff --git a/src/panels/config/entities/ha-config-entities.ts b/src/panels/config/entities/ha-config-entities.ts index 8a0dcc6f988a..b731e32d1ea9 100644 --- a/src/panels/config/entities/ha-config-entities.ts +++ b/src/panels/config/entities/ha-config-entities.ts @@ -539,8 +539,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { )} .hiddenLabel=${this.hass.localize( "ui.panel.config.entities.picker.filter.hidden_entities", - "number", - this._numHiddenEntities + { number: this._numHiddenEntities } )} .filter=${this._filter} selectable @@ -568,8 +567,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {

${this.hass.localize( "ui.panel.config.entities.picker.selected", - "number", - this._selectedEntities.length + { number: this._selectedEntities.length } )}

@@ -809,8 +807,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { showConfirmationDialog(this, { title: this.hass.localize( "ui.panel.config.entities.picker.enable_selected.confirm_title", - "number", - this._selectedEntities.length + { number: this._selectedEntities.length } ), text: this.hass.localize( "ui.panel.config.entities.picker.enable_selected.confirm_text" @@ -846,8 +843,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { showAlertDialog(this, { text: this.hass.localize( "ui.dialogs.entity_registry.editor.enabled_delay_confirm", - "delay", - reload_delay + { delay: reload_delay } ), }); } @@ -859,8 +855,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { showConfirmationDialog(this, { title: this.hass.localize( "ui.panel.config.entities.picker.disable_selected.confirm_title", - "number", - this._selectedEntities.length + { number: this._selectedEntities.length } ), text: this.hass.localize( "ui.panel.config.entities.picker.disable_selected.confirm_text" @@ -882,8 +877,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { showConfirmationDialog(this, { title: this.hass.localize( "ui.panel.config.entities.picker.hide_selected.confirm_title", - "number", - this._selectedEntities.length + { number: this._selectedEntities.length } ), text: this.hass.localize( "ui.panel.config.entities.picker.hide_selected.confirm_text" @@ -913,8 +907,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { ? "partly_" : "" }title`, - "number", - removeableEntities.length + { number: removeableEntities.length } ), text: removeableEntities.length === this._selectedEntities.length @@ -923,10 +916,10 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) { ) : this.hass.localize( "ui.panel.config.entities.picker.remove_selected.confirm_partly_text", - "removable", - removeableEntities.length, - "selected", - this._selectedEntities.length + { + removable: removeableEntities.length, + selected: this._selectedEntities.length, + } ), confirmText: this.hass.localize("ui.common.remove"), dismissText: this.hass.localize("ui.common.cancel"), diff --git a/src/panels/config/helpers/dialog-helper-detail.ts b/src/panels/config/helpers/dialog-helper-detail.ts index 76efa6e17e06..3eee77eaa6bd 100644 --- a/src/panels/config/helpers/dialog-helper-detail.ts +++ b/src/panels/config/helpers/dialog-helper-detail.ts @@ -224,8 +224,7 @@ export class DialogHelperDetail extends LitElement { ${this.hass.localize( "ui.dialogs.helper_settings.platform_not_loaded", - "platform", - domain + { platform: domain } )} ` @@ -249,10 +248,12 @@ export class DialogHelperDetail extends LitElement { this._domain ? this.hass.localize( "ui.panel.config.helpers.dialog.create_platform", - "platform", - this.hass.localize( - `ui.panel.config.helpers.types.${this._domain}` - ) || this._domain + { + platform: + this.hass.localize( + `ui.panel.config.helpers.types.${this._domain}` + ) || this._domain, + } ) : this.hass.localize("ui.panel.config.helpers.dialog.create_helper") )} diff --git a/src/panels/config/info/ha-config-info.ts b/src/panels/config/info/ha-config-info.ts index b1f4fafb316f..28c3bcaea53e 100644 --- a/src/panels/config/info/ha-config-info.ts +++ b/src/panels/config/info/ha-config-info.ts @@ -132,10 +132,7 @@ class HaConfigInfo extends LitElement { ${this.hass.localize( "ui.panel.config.info.frontend_version", - "version", - JS_VERSION, - "type", - JS_TYPE + { version: JS_VERSION, type: JS_TYPE } )}
diff --git a/src/panels/config/integrations/ha-config-flow-card.ts b/src/panels/config/integrations/ha-config-flow-card.ts index 2af91dcb2a3b..ad7df5b414b8 100644 --- a/src/panels/config/integrations/ha-config-flow-card.ts +++ b/src/panels/config/integrations/ha-config-flow-card.ts @@ -135,8 +135,7 @@ export class HaConfigFlowCard extends LitElement { const confirmed = await showConfirmationDialog(this, { title: this.hass!.localize( "ui.panel.config.integrations.ignore.confirm_ignore_title", - "name", - localizeConfigFlowTitle(this.hass.localize, this.flow) + { name: localizeConfigFlowTitle(this.hass.localize, this.flow) } ), text: this.hass!.localize( "ui.panel.config.integrations.ignore.confirm_ignore" diff --git a/src/panels/config/integrations/ha-config-integration-page.ts b/src/panels/config/integrations/ha-config-integration-page.ts index ab9bab716620..55c7cfc09f0c 100644 --- a/src/panels/config/integrations/ha-config-integration-page.ts +++ b/src/panels/config/integrations/ha-config-integration-page.ts @@ -305,8 +305,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) { `ui.panel.config.integrations.config_entry.${ services ? "services" : "devices" }`, - "count", - devices.length + { count: devices.length } )} @@ -323,8 +322,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) { > ${this.hass.localize( `ui.panel.config.integrations.config_entry.entities`, - "count", - entities.length + { count: entities.length } )} @@ -605,8 +603,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) { html`${this.hass.localize( `ui.panel.config.integrations.config_entry.${localizeKey}`, - "count", - items.length + { count: items.length } )}` ); @@ -619,8 +616,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) { href=${`/config/entities?historyBack=1&config_entry=${item.entry_id}`} >${this.hass.localize( "ui.panel.config.integrations.config_entry.entities", - "count", - entities.length + { count: entities.length } )}` ); @@ -729,8 +725,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) { ${this.hass.localize( `ui.panel.config.integrations.config_entry.devices`, - "count", - devices.length + { count: devices.length } )} @@ -749,8 +744,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) { > ${this.hass.localize( `ui.panel.config.integrations.config_entry.services`, - "count", - services.length + { count: services.length } )} @@ -767,8 +761,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) { > ${this.hass.localize( `ui.panel.config.integrations.config_entry.entities`, - "count", - entities.length + { count: entities.length } )} diff --git a/src/panels/config/integrations/ha-ignored-config-entry-card.ts b/src/panels/config/integrations/ha-ignored-config-entry-card.ts index 775343f7a7e1..f00d481d3794 100644 --- a/src/panels/config/integrations/ha-ignored-config-entry-card.ts +++ b/src/panels/config/integrations/ha-ignored-config-entry-card.ts @@ -47,8 +47,7 @@ export class HaIgnoredConfigEntryCard extends LitElement { showConfirmationDialog(this, { title: this.hass!.localize( "ui.panel.config.integrations.ignore.confirm_delete_ignore_title", - "name", - this.hass.localize(`component.${this.entry.domain}.title`) + { name: this.hass.localize(`component.${this.entry.domain}.title`) } ), text: this.hass!.localize( "ui.panel.config.integrations.ignore.confirm_delete_ignore" diff --git a/src/panels/config/integrations/ha-integration-card.ts b/src/panels/config/integrations/ha-integration-card.ts index 2ee7532b7efa..1a434fc51c0c 100644 --- a/src/panels/config/integrations/ha-integration-card.ts +++ b/src/panels/config/integrations/ha-integration-card.ts @@ -140,8 +140,7 @@ export class HaIntegrationCard extends LitElement { `ui.panel.config.integrations.config_entry.${ services ? "services" : "devices" }`, - "count", - devices.length + { count: devices.length } )} ` @@ -152,8 +151,7 @@ export class HaIntegrationCard extends LitElement { ${this.hass.localize( `ui.panel.config.integrations.config_entry.entities`, - "count", - entities.length + { count: entities.length } )} ` @@ -161,8 +159,7 @@ export class HaIntegrationCard extends LitElement { ${this.hass.localize( `ui.panel.config.integrations.config_entry.entries`, - "count", - this.items.length + { count: this.items.length } )} `} diff --git a/src/panels/config/integrations/integration-panels/mqtt/mqtt-subscribe-card.ts b/src/panels/config/integrations/integration-panels/mqtt/mqtt-subscribe-card.ts index b1bf864377d7..a4501073b132 100644 --- a/src/panels/config/integrations/integration-panels/mqtt/mqtt-subscribe-card.ts +++ b/src/panels/config/integrations/integration-panels/mqtt/mqtt-subscribe-card.ts @@ -110,15 +110,15 @@ class MqttSubscribeCard extends LitElement { ${this._messages.map( (msg) => html`
- ${this.hass.localize( - "ui.panel.config.mqtt.message_received", - "id", - msg.id, - "topic", - msg.message.topic, - "time", - formatTime(msg.time, this.hass!.locale, this.hass!.config) - )} + ${this.hass.localize("ui.panel.config.mqtt.message_received", { + id: msg.id, + topic: msg.message.topic, + time: formatTime( + msg.time, + this.hass!.locale, + this.hass!.config + ), + })}
${msg.payload}
QoS: ${msg.message.qos} - Retain: diff --git a/src/panels/config/integrations/integration-panels/zha/zha-device-card.ts b/src/panels/config/integrations/integration-panels/zha/zha-device-card.ts index 5d4f476491d3..9544fa6bc824 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-device-card.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-device-card.ts @@ -78,11 +78,9 @@ class ZHADeviceCard extends SubscribeMixin(LitElement) {
${this.device.model}
- ${this.hass.localize( - "ui.dialogs.zha_device_info.manuf", - "manufacturer", - this.device.manufacturer - )} + ${this.hass.localize("ui.dialogs.zha_device_info.manuf", { + manufacturer: this.device.manufacturer, + })}
@@ -191,8 +189,7 @@ class ZHADeviceCard extends SubscribeMixin(LitElement) { showAlertDialog(this, { text: this.hass.localize( "ui.panel.config.integrations.config_flow.error_saving_area", - "error", - err.message + { error: err.message } ), }); picker.value = null; diff --git a/src/panels/config/integrations/integration-panels/zha/zha-device-pairing-status-card.ts b/src/panels/config/integrations/integration-panels/zha/zha-device-pairing-status-card.ts index c4a8668ebd9c..a2b3cac37601 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-device-pairing-status-card.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-device-pairing-status-card.ts @@ -58,11 +58,9 @@ class ZHADevicePairingStatusCard extends LitElement { ? html`
${this.device.model}
- ${this.hass.localize( - "ui.dialogs.zha_device_info.manuf", - "manufacturer", - this.device.manufacturer - )} + ${this.hass.localize("ui.dialogs.zha_device_info.manuf", { + manufacturer: this.device.manufacturer, + })}
` : nothing} diff --git a/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-failed-node.ts b/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-failed-node.ts index a7a0494e4751..6b22e7a12ead 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-failed-node.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-failed-node.ts @@ -138,8 +138,7 @@ class DialogZWaveJSRemoveFailedNode extends LitElement {

${this.hass.localize( "ui.panel.config.zwave_js.remove_failed_node.removal_finished", - "id", - this._node!.node_id + { id: this._node!.node_id } )}

diff --git a/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-node.ts b/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-node.ts index 8db12606c420..461936dc44a4 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-node.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/dialog-zwave_js-remove-node.ts @@ -125,8 +125,7 @@ class DialogZWaveJSRemoveNode extends LitElement {

${this.hass.localize( "ui.panel.config.zwave_js.remove_node.exclusion_finished", - "id", - this._node!.node_id + { id: this._node!.node_id } )}

diff --git a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts index 0117e068da0b..df90deec4144 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts @@ -160,16 +160,17 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) { ${this.hass.localize( "ui.panel.config.zwave_js.node_config.attribution", - "device_database", - html`${this.hass.localize( - "ui.panel.config.zwave_js.node_config.zwave_js_device_database" - )}` + { + device_database: html`${this.hass.localize( + "ui.panel.config.zwave_js.node_config.zwave_js_device_database" + )}`, + } )}

@@ -184,8 +185,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {

${this.hass.localize( "ui.panel.config.zwave_js.node_config.endpoint", - "endpoint", - endpoint + { endpoint } )}

diff --git a/src/panels/config/logs/dialog-system-log-detail.ts b/src/panels/config/logs/dialog-system-log-detail.ts index 4856efdb980c..5e047d7b07b2 100644 --- a/src/panels/config/logs/dialog-system-log-detail.ts +++ b/src/panels/config/logs/dialog-system-log-detail.ts @@ -69,13 +69,11 @@ class DialogSystemLogDetail extends LitElement { // Custom components with our official docs should not link to our docs !this._manifest.documentation.includes("://www.home-assistant.io")); - const title = this.hass.localize( - "ui.panel.config.logs.details", - "level", - html`${this.hass.localize(`ui.panel.config.logs.level.${item.level}`)}` - ); + >`, + }); return html` diff --git a/src/panels/config/logs/error-log-card.ts b/src/panels/config/logs/error-log-card.ts index aa0493ddd2e5..3e688149cc9c 100644 --- a/src/panels/config/logs/error-log-card.ts +++ b/src/panels/config/logs/error-log-card.ts @@ -179,10 +179,8 @@ class ErrorLogCard extends LitElement { } catch (err: any) { this._error = this.hass.localize( "ui.panel.config.logs.failed_get_logs", - "provider", - this.provider, - "error", - extractApiErrorMessage(err) + {provider:this.provider, + error:extractApiErrorMessage(err)} ); return; } diff --git a/src/panels/config/logs/system-log-card.ts b/src/panels/config/logs/system-log-card.ts index e05da8a75dd5..dbaa91062486 100644 --- a/src/panels/config/logs/system-log-card.ts +++ b/src/panels/config/logs/system-log-card.ts @@ -46,17 +46,14 @@ export class SystemLogCard extends LitElement { } private _multipleMessages(item: LoggedError): string { - return this.hass.localize( - "ui.panel.config.logs.multiple_messages", - "time", - formatSystemLogTime( + return this.hass.localize("ui.panel.config.logs.multiple_messages", { + time: formatSystemLogTime( item.first_occurred, this.hass.locale, this.hass.config ), - "counter", - item.count - ); + counter: item.count, + }); } private _getFilteredItems = memoizeOne( @@ -112,8 +109,7 @@ export class SystemLogCard extends LitElement { ? html`
${this.hass.localize( "ui.panel.config.logs.no_issues_search", - "term", - this.filter + { term: this.filter } )}
` : filteredItems.map( diff --git a/src/panels/config/network/supervisor-network.ts b/src/panels/config/network/supervisor-network.ts index faaa0a21006f..db6d00a08642 100644 --- a/src/panels/config/network/supervisor-network.ts +++ b/src/panels/config/network/supervisor-network.ts @@ -116,8 +116,7 @@ export class HassioNetwork extends LitElement { ? html`

${this.hass.localize( "ui.panel.config.network.supervisor.connected_to", - "ssid", - this._interface?.wifi?.ssid + { ssid: this._interface?.wifi?.ssid } )}

` : ""} diff --git a/src/panels/config/person/dialog-person-detail.ts b/src/panels/config/person/dialog-person-detail.ts index 9273ea02f82a..92ee079d7d27 100644 --- a/src/panels/config/person/dialog-person-detail.ts +++ b/src/panels/config/person/dialog-person-detail.ts @@ -306,8 +306,7 @@ class DialogPersonDetail extends LitElement { !(await showConfirmationDialog(this, { text: this.hass!.localize( "ui.panel.config.person.detail.confirm_delete_user", - "name", - this._name + { name: this._name } ), confirmText: this.hass!.localize( "ui.panel.config.person.detail.delete" diff --git a/src/panels/config/scene/ha-scene-editor.ts b/src/panels/config/scene/ha-scene-editor.ts index 5c7aba3f3bf7..816b63100156 100644 --- a/src/panels/config/scene/ha-scene-editor.ts +++ b/src/panels/config/scene/ha-scene-editor.ts @@ -587,8 +587,7 @@ export class HaSceneEditor extends SubscribeMixin( ) : this.hass.localize( "ui.panel.config.scene.editor.load_error_unknown", - "err_no", - err.status_code + { err_no: err.status_code } ), }); history.back(); diff --git a/src/panels/config/script/ha-script-editor.ts b/src/panels/config/script/ha-script-editor.ts index 6d43660242b2..1ed7527f3ca5 100644 --- a/src/panels/config/script/ha-script-editor.ts +++ b/src/panels/config/script/ha-script-editor.ts @@ -465,8 +465,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { ) : this.hass.localize( "ui.panel.config.script.editor.load_error_unknown", - "err_no", - resp.status_code || resp.code + { err_no: resp.status_code || resp.code } ) ); history.back(); @@ -610,11 +609,9 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { ev.stopPropagation(); await triggerScript(this.hass, this.scriptId!); showToast(this, { - message: this.hass.localize( - "ui.notification_toast.triggered", - "name", - this._config!.alias - ), + message: this.hass.localize("ui.notification_toast.triggered", { + name: this._config!.alias, + }), }); } diff --git a/src/panels/config/script/ha-script-picker.ts b/src/panels/config/script/ha-script-picker.ts index 179acd6c21ae..59a05f6b9e8b 100644 --- a/src/panels/config/script/ha-script-picker.ts +++ b/src/panels/config/script/ha-script-picker.ts @@ -303,10 +303,12 @@ class HaScriptPicker extends LitElement { this._activeFilters = [ this.hass.localize( "ui.panel.config.script.picker.filtered_by_blueprint", - "name", - !blueprintMeta || "error" in blueprintMeta - ? blueprint - : blueprintMeta.metadata.name || blueprint + { + name: + !blueprintMeta || "error" in blueprintMeta + ? blueprint + : blueprintMeta.metadata.name || blueprint, + } ), ]; } @@ -353,11 +355,9 @@ class HaScriptPicker extends LitElement { } await triggerScript(this.hass, entry.unique_id); showToast(this, { - message: this.hass.localize( - "ui.notification_toast.triggered", - "name", - computeStateName(script) - ), + message: this.hass.localize("ui.notification_toast.triggered", { + name: computeStateName(script), + }), }); }; @@ -419,8 +419,7 @@ class HaScriptPicker extends LitElement { await showAlertDialog(this, { text: this.hass.localize( "ui.panel.config.script.editor.load_error_unknown", - "err_no", - err.status_code + { err_no: err.status_code } ), }); } @@ -459,8 +458,7 @@ class HaScriptPicker extends LitElement { ) : this.hass.localize( "ui.panel.config.script.editor.load_error_unknown", - "err_no", - err.status_code + { err_no: err.status_code } ), }); } diff --git a/src/panels/config/tags/dialog-tag-detail.ts b/src/panels/config/tags/dialog-tag-detail.ts index 0026fa466858..7f402f2d4a4d 100644 --- a/src/panels/config/tags/dialog-tag-detail.ts +++ b/src/panels/config/tags/dialog-tag-detail.ts @@ -118,18 +118,16 @@ class DialogTagDetail ? html`

- ${this.hass!.localize( - "ui.panel.config.tag.detail.usage", - "companion_link", - html`${this.hass!.localize( "ui.panel.config.tag.detail.companion_apps" )}` - )} + >`, + })}

${this._qrCode @@ -251,11 +249,9 @@ class DialogTagDetail ); this._qrCode = html`${this.hass.localize(`; } diff --git a/src/panels/config/tags/ha-config-tags.ts b/src/panels/config/tags/ha-config-tags.ts index 4ac788eba29c..5eb80452e232 100644 --- a/src/panels/config/tags/ha-config-tags.ts +++ b/src/panels/config/tags/ha-config-tags.ts @@ -207,11 +207,9 @@ export class HaConfigTags extends SubscribeMixin(LitElement) { private _handleAutomationClick = (ev: Event) => { const tag = (ev.currentTarget as any).tag; const data = { - alias: this.hass.localize( - "ui.panel.config.tag.automation_title", - "name", - tag.name || tag.id - ), + alias: this.hass.localize("ui.panel.config.tag.automation_title", { + name: tag.name || tag.id, + }), trigger: [{ platform: "tag", tag_id: tag.id } as TagTrigger], }; showAutomationEditor(data); @@ -225,18 +223,16 @@ export class HaConfigTags extends SubscribeMixin(LitElement) { title: this.hass.localize("ui.panel.config.tag.caption"), text: html`

- ${this.hass.localize( - "ui.panel.config.tag.detail.usage", - "companion_link", - html`${this.hass!.localize( "ui.panel.config.tag.detail.companion_apps" )}` - )} + >`, + })}

${this.hass.localize( "ui.panel.config.entities.picker.selected", - "number", - this._selectedEntities.length + { number: this._selectedEntities.length } )}

diff --git a/src/panels/custom/ha-panel-custom.ts b/src/panels/custom/ha-panel-custom.ts index 203983d64cc5..9d685a18932e 100644 --- a/src/panels/custom/ha-panel-custom.ts +++ b/src/panels/custom/ha-panel-custom.ts @@ -102,10 +102,7 @@ export class HaPanelCustom extends ReactiveElement { !confirm( `${this.hass.localize( "ui.panel.custom.external_panel.question_trust", - "name", - config.name, - "link", - tempA.href + { name: config.name, link: tempA.href } )} ${this.hass.localize( diff --git a/src/panels/developer-tools/event/event-subscribe-card.ts b/src/panels/developer-tools/event/event-subscribe-card.ts index d6fc03547485..628ddfd8ef87 100644 --- a/src/panels/developer-tools/event/event-subscribe-card.ts +++ b/src/panels/developer-tools/event/event-subscribe-card.ts @@ -74,8 +74,7 @@ class EventSubscribeCard extends LitElement {
${this.hass!.localize( "ui.panel.developer-tools.tabs.events.event_fired", - "name", - event.id + { name: event.id } )} ${formatTime( new Date(event.event.time_fired), diff --git a/src/panels/developer-tools/service/developer-tools-service.ts b/src/panels/developer-tools/service/developer-tools-service.ts index 8ffd198e784d..1d88b0777107 100644 --- a/src/panels/developer-tools/service/developer-tools-service.ts +++ b/src/panels/developer-tools/service/developer-tools-service.ts @@ -380,11 +380,9 @@ class HaPanelDevService extends LitElement { button.actionError(); showToast(this, { message: - this.hass.localize( - "ui.notification_toast.service_call_failed", - "service", - this._serviceData.service - ) + ` ${err.message}`, + this.hass.localize("ui.notification_toast.service_call_failed", { + service: this._serviceData.service, + }) + ` ${err.message}`, }); return; } diff --git a/src/panels/developer-tools/yaml_configuration/developer-yaml-config.ts b/src/panels/developer-tools/yaml_configuration/developer-yaml-config.ts index 9d1545b1a41e..48f12e85c7a0 100644 --- a/src/panels/developer-tools/yaml_configuration/developer-yaml-config.ts +++ b/src/panels/developer-tools/yaml_configuration/developer-yaml-config.ts @@ -159,8 +159,7 @@ export class DeveloperYamlConfig extends LitElement { ) || this.hass.localize( "ui.panel.developer-tools.tabs.yaml.section.reloading.reload", - "domain", - domainToName(this.hass.localize, domain) + { domain: domainToName(this.hass.localize, domain) } )}
diff --git a/src/panels/lovelace/cards/hui-gauge-card.ts b/src/panels/lovelace/cards/hui-gauge-card.ts index 8edb38253a90..020440806367 100644 --- a/src/panels/lovelace/cards/hui-gauge-card.ts +++ b/src/panels/lovelace/cards/hui-gauge-card.ts @@ -104,8 +104,7 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { ${this.hass.localize( "ui.panel.lovelace.warning.entity_unavailable", - "entity", - this._config.entity + { entity: this._config.entity } )} `; @@ -116,8 +115,7 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { ${this.hass.localize( "ui.panel.lovelace.warning.entity_non_numeric", - "entity", - this._config.entity + { entity: this._config.entity } )} `; diff --git a/src/panels/lovelace/cards/hui-logbook-card.ts b/src/panels/lovelace/cards/hui-logbook-card.ts index 590220eb4786..d73e246eb1c4 100644 --- a/src/panels/lovelace/cards/hui-logbook-card.ts +++ b/src/panels/lovelace/cards/hui-logbook-card.ts @@ -106,11 +106,9 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard { if (!isComponentLoaded(this.hass, "logbook")) { return html` - ${this.hass.localize( - "ui.components.logbook.not_loaded", - "platform", - "logbook" - )} `; } diff --git a/src/panels/lovelace/cards/hui-weather-forecast-card.ts b/src/panels/lovelace/cards/hui-weather-forecast-card.ts index dec8eac04cbb..b87dbef2c7fc 100644 --- a/src/panels/lovelace/cards/hui-weather-forecast-card.ts +++ b/src/panels/lovelace/cards/hui-weather-forecast-card.ts @@ -212,11 +212,9 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard { if (stateObj.state === UNAVAILABLE) { return html` - ${this.hass.localize( - "ui.panel.lovelace.warning.entity_unavailable", - "entity", - `${computeStateName(stateObj)} (${this._config.entity})` - )} + ${this.hass.localize("ui.panel.lovelace.warning.entity_unavailable", { + entity: `${computeStateName(stateObj)} (${this._config.entity})`, + })} `; } diff --git a/src/panels/lovelace/common/compute-tooltip.ts b/src/panels/lovelace/common/compute-tooltip.ts index d6dc844a0740..50b5b0485f97 100644 --- a/src/panels/lovelace/common/compute-tooltip.ts +++ b/src/panels/lovelace/common/compute-tooltip.ts @@ -20,50 +20,33 @@ function computeActionTooltip( return ""; } - let tooltip = + return ( (isHold ? hass.localize("ui.panel.lovelace.cards.picture-elements.hold") - : hass.localize("ui.panel.lovelace.cards.picture-elements.tap")) + " "; - - switch (config.action) { - case "navigate": - tooltip += `${hass.localize( - "ui.panel.lovelace.cards.picture-elements.navigate_to", - "location", - config.navigation_path - )}`; - break; - case "url": - tooltip += `${hass.localize( - "ui.panel.lovelace.cards.picture-elements.url", - "url_path", - config.url_path - )}`; - break; - case "toggle": - tooltip += `${hass.localize( - "ui.panel.lovelace.cards.picture-elements.toggle", - "name", - state - )}`; - break; - case "call-service": - tooltip += `${hass.localize( - "ui.panel.lovelace.cards.picture-elements.call_service", - "name", - config.service - )}`; - break; - case "more-info": - tooltip += `${hass.localize( - "ui.panel.lovelace.cards.picture-elements.more_info", - "name", - state - )}`; - break; - } - - return tooltip; + : hass.localize("ui.panel.lovelace.cards.picture-elements.tap")) + + " " + + (config.action === "navigate" + ? hass.localize("ui.panel.lovelace.cards.picture-elements.navigate_to", { + location: config.navigation_path, + }) + : config.action === "url" + ? hass.localize("ui.panel.lovelace.cards.picture-elements.url", { + url_path: config.url_path, + }) + : config.action === "toggle" + ? hass.localize("ui.panel.lovelace.cards.picture-elements.toggle", { + name: state, + }) + : config.action === "call-service" + ? hass.localize("ui.panel.lovelace.cards.picture-elements.call_service", { + name: config.service, + }) + : config.action === "more-info" + ? hass.localize("ui.panel.lovelace.cards.picture-elements.more_info", { + name: state, + }) + : "") + ); } export const computeTooltip = (hass: HomeAssistant, config: Config): string => { diff --git a/src/panels/lovelace/common/generate-lovelace-config.ts b/src/panels/lovelace/common/generate-lovelace-config.ts index f8dfa99cc30e..3a54e7ab7fe7 100644 --- a/src/panels/lovelace/common/generate-lovelace-config.ts +++ b/src/panels/lovelace/common/generate-lovelace-config.ts @@ -537,13 +537,11 @@ export const generateDefaultViewConfig = ( title: device.name_by_user || device.name || - localize( - "ui.panel.config.devices.unnamed_device", - "type", - localize( + localize("ui.panel.config.devices.unnamed_device", { + type: localize( `ui.panel.config.devices.type.${device.entry_type || "device"}` - ) - ), + ), + }), } ) ); diff --git a/src/panels/lovelace/common/handle-action.ts b/src/panels/lovelace/common/handle-action.ts index bd849bd42836..9d3166233626 100644 --- a/src/panels/lovelace/common/handle-action.ts +++ b/src/panels/lovelace/common/handle-action.ts @@ -74,15 +74,14 @@ export const handleAction = async ( !(await showConfirmationDialog(node, { text: actionConfig.confirmation.text || - hass.localize( - "ui.panel.lovelace.cards.actions.action_confirmation", - "action", - serviceName || + hass.localize("ui.panel.lovelace.cards.actions.action_confirmation", { + action: + serviceName || hass.localize( `ui.panel.lovelace.editor.action-editor.actions.${actionConfig.action}` ) || - actionConfig.action - ), + actionConfig.action, + }), })) ) { return; diff --git a/src/panels/lovelace/components/hui-warning.ts b/src/panels/lovelace/components/hui-warning.ts index 20f59819c249..3a70741a47c4 100644 --- a/src/panels/lovelace/components/hui-warning.ts +++ b/src/panels/lovelace/components/hui-warning.ts @@ -9,11 +9,9 @@ export const createEntityNotFoundWarning = ( entityId: string ) => hass.config.state !== STATE_NOT_RUNNING - ? hass.localize( - "ui.panel.lovelace.warning.entity_not_found", - "entity", - entityId || "[empty]" - ) + ? hass.localize("ui.panel.lovelace.warning.entity_not_found", { + entity: entityId || "[empty]", + }) : hass.localize("ui.panel.lovelace.warning.starting"); @customElement("hui-warning") diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts index e7a2bbcb51f4..ace3d7138288 100644 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts @@ -69,8 +69,7 @@ export class HuiCreateDialogCard const title = this._viewConfig.title ? this.hass!.localize( "ui.panel.lovelace.editor.edit_card.pick_card_view_title", - "name", - `"${this._viewConfig.title}"` + { name: `"${this._viewConfig.title}"` } ) : this.hass!.localize("ui.panel.lovelace.editor.edit_card.pick_card"); diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts index f881cb6f57eb..b145b1c4f916 100644 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts @@ -149,17 +149,17 @@ export class HuiDialogEditCard if (this._cardConfig && this._cardConfig.type) { heading = this.hass!.localize( "ui.panel.lovelace.editor.edit_card.typed_header", - "type", - this.hass!.localize( - `ui.panel.lovelace.editor.card.${this._cardConfig.type}.name` - ) + { + type: this.hass!.localize( + `ui.panel.lovelace.editor.card.${this._cardConfig.type}.name` + ), + } ); } else if (!this._cardConfig) { heading = this._viewConfig.title ? this.hass!.localize( "ui.panel.lovelace.editor.edit_card.pick_card_view_title", - "name", - `"${this._viewConfig.title}"` + { name: `"${this._viewConfig.title}"` } ) : this.hass!.localize("ui.panel.lovelace.editor.edit_card.pick_card"); } else { diff --git a/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts b/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts index 092dd0213475..f3d25a213030 100644 --- a/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts +++ b/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts @@ -45,10 +45,11 @@ export class HuiCreateDialogHeaderFooter this.hass, this.hass!.localize( `ui.panel.lovelace.editor.header-footer.choose_header_footer`, - "type", - this.hass!.localize( - `ui.panel.lovelace.editor.header-footer.${this._params.type}` - ) + { + type: this.hass!.localize( + `ui.panel.lovelace.editor.header-footer.${this._params.type}` + ), + } ) )} @keydown=${this._ignoreKeydown} diff --git a/src/panels/lovelace/editor/hui-element-editor.ts b/src/panels/lovelace/editor/hui-element-editor.ts index 2d2b58f4a10f..2de39a3f95d9 100644 --- a/src/panels/lovelace/editor/hui-element-editor.ts +++ b/src/panels/lovelace/editor/hui-element-editor.ts @@ -234,11 +234,9 @@ export abstract class HuiElementEditor extends LitElement { ${this._guiSupported === false && this.configElementType ? html`
- ${this.hass.localize( - "ui.errors.config.editor_not_available", - "type", - this.configElementType - )} + ${this.hass.localize("ui.errors.config.editor_not_available", { + type: this.configElementType, + })}
` : ""} diff --git a/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts b/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts index d873e8d5e129..027865fd7ca4 100644 --- a/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts +++ b/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts @@ -129,8 +129,7 @@ export class HuiDialogEditView extends LitElement { return this.hass!.localize( "ui.panel.lovelace.editor.edit_view.header_name", - "name", - this._config.title + { name: this._config.title } ); } @@ -367,10 +366,10 @@ export class HuiDialogEditView extends LitElement { `ui.panel.lovelace.views.confirm_delete${ this._cards?.length ? "_existing_cards" : "" }_text`, - "name", - this._config?.title || "Unnamed view", - "number", - this._cards?.length || 0 + { + name: this._config?.title || "Unnamed view", + number: this._cards?.length || 0, + } ), confirm: () => this._delete(), }); diff --git a/src/panels/lovelace/elements/hui-state-label-element.ts b/src/panels/lovelace/elements/hui-state-label-element.ts index a0427bdbcd22..e19f39f5c517 100644 --- a/src/panels/lovelace/elements/hui-state-label-element.ts +++ b/src/panels/lovelace/elements/hui-state-label-element.ts @@ -60,10 +60,7 @@ class HuiStateLabelElement extends LitElement implements LovelaceElement { `; diff --git a/src/panels/lovelace/entity-rows/hui-script-entity-row.ts b/src/panels/lovelace/entity-rows/hui-script-entity-row.ts index 5e97a255397c..050209570ac6 100644 --- a/src/panels/lovelace/entity-rows/hui-script-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-script-entity-row.ts @@ -53,12 +53,11 @@ class HuiScriptEntityRow extends LitElement implements LovelaceRow { ${stateObj.state === "on" ? html` ${stateObj.attributes.mode !== "single" && - (stateObj.attributes.current || 0) > 0 - ? this.hass.localize( - "ui.card.script.cancel_multiple", - "number", - stateObj.attributes.current - ) + stateObj.attributes.current && + stateObj.attributes.current > 0 + ? this.hass.localize("ui.card.script.cancel_multiple", { + number: stateObj.attributes.current, + }) : this.hass.localize("ui.card.script.cancel")} ` : ""} diff --git a/src/panels/lovelace/hui-editor.ts b/src/panels/lovelace/hui-editor.ts index 9bf7cb9cc511..1b1894e2b660 100644 --- a/src/panels/lovelace/hui-editor.ts +++ b/src/panels/lovelace/hui-editor.ts @@ -204,8 +204,7 @@ class LovelaceFullConfigEditor extends LitElement { showAlertDialog(this, { text: this.hass.localize( "ui.panel.lovelace.editor.raw_editor.error_remove", - "error", - err + { error: err } ), }); } @@ -254,8 +253,7 @@ class LovelaceFullConfigEditor extends LitElement { showAlertDialog(this, { text: this.hass.localize( "ui.panel.lovelace.editor.raw_editor.error_parse_yaml", - "error", - err + { error: err } ), }); this._saving = false; @@ -267,8 +265,7 @@ class LovelaceFullConfigEditor extends LitElement { showAlertDialog(this, { text: this.hass.localize( "ui.panel.lovelace.editor.raw_editor.error_invalid_config", - "error", - err + { error: err } ), }); return; @@ -287,8 +284,7 @@ class LovelaceFullConfigEditor extends LitElement { showAlertDialog(this, { text: this.hass.localize( "ui.panel.lovelace.editor.raw_editor.error_save_yaml", - "error", - err + { error: err } ), }); } diff --git a/src/panels/mailbox/ha-panel-mailbox.ts b/src/panels/mailbox/ha-panel-mailbox.ts index 04c155fde584..4dd210133caa 100644 --- a/src/panels/mailbox/ha-panel-mailbox.ts +++ b/src/panels/mailbox/ha-panel-mailbox.ts @@ -89,11 +89,9 @@ class HaPanelMailbox extends LitElement {
${message.caller}
- ${this.hass.localize( - "ui.duration.second", - "count", - message.duration - )} + ${this.hass.localize("ui.duration.second", { + count: message.duration, + })}
diff --git a/src/panels/my/ha-panel-my.ts b/src/panels/my/ha-panel-my.ts index 9810837ccfbf..a71054a63d14 100644 --- a/src/panels/my/ha-panel-my.ts +++ b/src/panels/my/ha-panel-my.ts @@ -375,74 +375,55 @@ class HaPanelMy extends LitElement { } protected render() { - if (this._error) { - let error: string; - switch (this._error) { - case "not_supported": - error = - this.hass.localize( - "ui.panel.my.not_supported", - "link", - html`${this.hass.localize("ui.panel.my.faq_link")}` - ) || "This redirect is not supported."; - break; - case "no_component": - error = - this.hass.localize( - "ui.panel.my.component_not_loaded", - "integration", - html`${domainToName( - this.hass.localize, - this._redirect!.component! - )}` - ) || "This redirect is not supported."; - break; - case "no_supervisor": - error = this.hass.localize( - "ui.panel.my.no_supervisor", - "docs_link", - html`${this.hass.localize("ui.panel.my.faq_link")}`, + }) || "This redirect is not supported." + : this._error === "no_component" + ? this.hass.localize("ui.panel.my.component_not_loaded", { + integration: html`${domainToName( + this.hass.localize, + this._redirect!.component! + )}`, + }) || "This redirect is not supported." + : this._error === "no_supervisor" + ? this.hass.localize("ui.panel.my.no_supervisor", { + docs_link: html`${this.hass.localize("ui.panel.my.documentation")}` - ); - break; - case "not_app": - error = this.hass.localize( - "ui.panel.my.not_app", - "link", - html``, + }) + : this._error === "not_app" + ? this.hass.localize("ui.panel.my.not_app", { + link: html`${this.hass.localize("ui.panel.my.download_app")}` - ); - break; - default: - error = this.hass.localize("ui.panel.my.error") || "Unknown error"; - } - return html``; - } - return nothing; + >`, + }) + : this.hass.localize("ui.panel.my.error") || "Unknown error"; + return html``; } private _createRedirectUrl(): string { diff --git a/src/panels/profile/dialog-ha-mfa-module-setup-flow.ts b/src/panels/profile/dialog-ha-mfa-module-setup-flow.ts index e5e9ff4abe78..94b0a6f4eb56 100644 --- a/src/panels/profile/dialog-ha-mfa-module-setup-flow.ts +++ b/src/panels/profile/dialog-ha-mfa-module-setup-flow.ts @@ -97,8 +97,7 @@ class HaMfaModuleSetupFlow extends LitElement { ? html`

${this.hass.localize( "ui.panel.profile.mfa_setup.step_done", - "step", - this._step.title + { step: this._step.title } )}

` : this._step.type === "form" diff --git a/src/panels/profile/ha-long-lived-access-token-dialog.ts b/src/panels/profile/ha-long-lived-access-token-dialog.ts index 7841e4918ae1..4dd9fe129881 100644 --- a/src/panels/profile/ha-long-lived-access-token-dialog.ts +++ b/src/panels/profile/ha-long-lived-access-token-dialog.ts @@ -115,8 +115,7 @@ export class HaLongLivedAccessTokenDialog extends LitElement { this._qrCode = html`${this.hass.localize(`; diff --git a/src/panels/profile/ha-long-lived-access-tokens-card.ts b/src/panels/profile/ha-long-lived-access-tokens-card.ts index c622ad0d7e85..a835f9898695 100644 --- a/src/panels/profile/ha-long-lived-access-tokens-card.ts +++ b/src/panels/profile/ha-long-lived-access-tokens-card.ts @@ -67,11 +67,12 @@ class HaLongLivedTokens extends LitElement {
${this.hass.localize( "ui.panel.profile.long_lived_access_tokens.created", - "date", - relativeTime( - new Date(token.created_at), - this.hass.locale - ) + { + date: relativeTime( + new Date(token.created_at), + this.hass.locale + ), + } )}
${stateObj.attributes.mode !== "single" && - (stateObj.attributes.current || 0) > 0 - ? this.hass.localize( - "ui.card.script.cancel_multiple", - "number", - stateObj.attributes.current - ) + stateObj.attributes.current && + stateObj.attributes.current > 0 + ? this.hass.localize("ui.card.script.cancel_multiple", { + number: stateObj.attributes.current, + }) : this.hass.localize("ui.card.script.cancel")} ` : ""} diff --git a/src/state/disconnect-toast-mixin.ts b/src/state/disconnect-toast-mixin.ts index c74773c91325..d45d873bdd74 100644 --- a/src/state/disconnect-toast-mixin.ts +++ b/src/state/disconnect-toast-mixin.ts @@ -121,11 +121,9 @@ export default >(superClass: T) => showToast(this, { message: - this.hass!.localize( - "ui.notification_toast.integration_starting", - "integration", - domainToName(this.hass!.localize, integration) - ) || + this.hass!.localize("ui.notification_toast.integration_starting", { + integration: domainToName(this.hass!.localize, integration), + }) || `Starting ${integration}, not everything will be available until it is finished.`, duration: 0, dismissable: false, diff --git a/src/translations/en.json b/src/translations/en.json index 33ac44cddbcf..fb040bbe455b 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2662,7 +2662,7 @@ "delete": "[%key:ui::common::delete%]", "delete_confirm_title": "Delete action?", "delete_confirm_text": "[%key:ui::panel::config::automation::editor::triggers::delete_confirm_text%]", - "unsupported_action": "No visual editor support for action: {action}", + "unsupported_action": "No visual editor support for this action", "type_select": "Action type", "continue_on_error": "Continue on error", "type": { From d21a978e6172a691bff5c11de9c9dfd48d01b010 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Mon, 25 Sep 2023 17:00:05 -0700 Subject: [PATCH 03/12] fix undefines --- hassio/src/addon-view/hassio-addon-dashboard.ts | 2 +- hassio/src/addon-view/info/hassio-addon-info.ts | 2 +- .../update-available/update-available-card.ts | 2 +- src/auth/ha-auth-flow.ts | 2 +- src/common/translations/localize.ts | 7 ++++++- src/components/ha-area-picker.ts | 2 +- src/components/ha-assist-pipeline-picker.ts | 17 ++++++++++------- src/components/ha-file-upload.ts | 2 +- src/data/automation_i18n.ts | 4 ++-- src/data/script_i18n.ts | 17 +++++++++++------ src/dialogs/more-info/ha-more-info-info.ts | 2 +- .../configurator-notification-item.ts | 2 +- .../config/automation/ha-automation-editor.ts | 2 +- .../ha-disabled-config-entry-card.ts | 2 +- src/panels/config/logs/error-log-card.ts | 3 +-- src/panels/config/repairs/ha-config-repairs.ts | 2 +- src/panels/config/scene/ha-scene-editor.ts | 2 +- src/panels/config/script/ha-script-editor.ts | 2 +- .../cards/energy/hui-energy-gas-graph-card.ts | 2 +- .../cards/energy/hui-energy-water-graph-card.ts | 2 +- src/panels/profile/ha-refresh-tokens-card.ts | 2 +- 21 files changed, 46 insertions(+), 34 deletions(-) diff --git a/hassio/src/addon-view/hassio-addon-dashboard.ts b/hassio/src/addon-view/hassio-addon-dashboard.ts index 4bb888290fac..0ae5370b2c70 100644 --- a/hassio/src/addon-view/hassio-addon-dashboard.ts +++ b/hassio/src/addon-view/hassio-addon-dashboard.ts @@ -183,7 +183,7 @@ class HassioAddonDashboard extends LitElement { if (this.route.path === "") { const requestedAddon = extractSearchParam("addon"); const requestedAddonRepository = extractSearchParam("repository_url"); - if (requestedAddonRepository) { + if (requestedAddon && requestedAddonRepository) { const storeInfo = await fetchSupervisorStore(this.hass); if ( !storeInfo.repositories.find( diff --git a/hassio/src/addon-view/info/hassio-addon-info.ts b/hassio/src/addon-view/info/hassio-addon-info.ts index 7a935518cc32..0fb8800b331f 100644 --- a/hassio/src/addon-view/info/hassio-addon-info.ts +++ b/hassio/src/addon-view/info/hassio-addon-info.ts @@ -577,7 +577,7 @@ class HassioAddonInfo extends LitElement { "addon.dashboard.not_available_version", { core_version_installed: this.supervisor.core.version, - core_version_needed: addonStoreInfo!.homeassistant, + core_version_needed: addonStoreInfo!.homeassistant!, } )} diff --git a/hassio/src/update-available/update-available-card.ts b/hassio/src/update-available/update-available-card.ts index c9fcb74d5e8e..86988c010a54 100644 --- a/hassio/src/update-available/update-available-card.ts +++ b/hassio/src/update-available/update-available-card.ts @@ -312,7 +312,7 @@ class UpdateAvailableCard extends LitElement { "addon.dashboard.not_available_version", { core_version_installed: this.supervisor.core.version, - core_version_needed: addonStoreInfo.homeassistant, + core_version_needed: addonStoreInfo.homeassistant!, } ); } diff --git a/src/auth/ha-auth-flow.ts b/src/auth/ha-auth-flow.ts index e0841ebe3803..2a90c3071c9d 100644 --- a/src/auth/ha-auth-flow.ts +++ b/src/auth/ha-auth-flow.ts @@ -160,7 +160,7 @@ export class HaAuthFlow extends LitElement { return html` ${this.localize("ui.panel.page-authorize.form.error", { - error: this._errorMessage, + error: this._errorMessage!, })}
diff --git a/src/common/translations/localize.ts b/src/common/translations/localize.ts index f40c11b8ea48..8cff8c6c58ff 100644 --- a/src/common/translations/localize.ts +++ b/src/common/translations/localize.ts @@ -1,4 +1,5 @@ import IntlMessageFormat from "intl-messageformat"; +import type { HTMLTemplateResult } from "lit"; import { polyfillLocaleData } from "../../resources/locale-data-polyfill"; import { Resources, TranslationDict } from "../../types"; @@ -42,7 +43,7 @@ export type FlattenObjectKeys< export type LocalizeFunc = ( key: Keys, - values?: Record + values?: Record ) => string; interface FormatType { @@ -101,6 +102,10 @@ export const computeLocalize = async ( const args = _args as any; if (args.length === 1 && typeof args[0] === "object") { argObject = args[0]; + if (Object.values(argObject).some((v) => v === undefined)) { + // eslint-disable-next-line no-console + console.warn("[FIXME] While localizing", key, "undefined was passed"); + } } else if (args.length >= 2) { // eslint-disable-next-line no-console console.warn("[FIXME] While localizing", key, "old format was passed"); diff --git a/src/components/ha-area-picker.ts b/src/components/ha-area-picker.ts index 5d56c6908203..9ed8cdf709f5 100644 --- a/src/components/ha-area-picker.ts +++ b/src/components/ha-area-picker.ts @@ -364,7 +364,7 @@ export class HaAreaPicker extends LitElement { area_id: "add_new_suggestion", name: this.hass.localize( "ui.components.area-picker.add_new_sugestion", - { name: this._suggestion } + { name: this._suggestion! } ), picture: null, }, diff --git a/src/components/ha-assist-pipeline-picker.ts b/src/components/ha-assist-pipeline-picker.ts index 80a69b2d2799..60a6aae1816a 100644 --- a/src/components/ha-assist-pipeline-picker.ts +++ b/src/components/ha-assist-pipeline-picker.ts @@ -46,6 +46,9 @@ export class HaAssistPipelinePicker extends LitElement { return nothing; } const value = this.value ?? this._default; + const preferredPipeline = this._pipelines.find( + (pipeline) => pipeline.id === this._preferredPipeline + ); return html` ` : null} - - ${this.hass!.localize("ui.components.pipeline-picker.preferred", { - preferred: this._pipelines.find( - (pipeline) => pipeline.id === this._preferredPipeline - )?.name, - })} - + ${preferredPipeline + ? html` + ${this.hass!.localize("ui.components.pipeline-picker.preferred", { + preferred: preferredPipeline.name, + })} + ` + : null} ${this._pipelines.map( (pipeline) => html` diff --git a/src/components/ha-file-upload.ts b/src/components/ha-file-upload.ts index cc0e97a29c72..7c2b133ae308 100644 --- a/src/components/ha-file-upload.ts +++ b/src/components/ha-file-upload.ts @@ -64,7 +64,7 @@ export class HaFileUpload extends LitElement { >${this.value ? this.hass?.localize( "ui.components.file-upload.uploading_name", - { name: this.value } + { name: this.value.toString() } ) : this.hass?.localize( "ui.components.file-upload.uploading" diff --git a/src/data/automation_i18n.ts b/src/data/automation_i18n.ts index 244fad1ba3ef..aa3d72bd0746 100644 --- a/src/data/automation_i18n.ts +++ b/src/data/automation_i18n.ts @@ -336,7 +336,7 @@ const tryDescribeTrigger = ( trigger.event === "sunset" ? `${triggerTranslationBaseKey}.sun.description.sets` : `${triggerTranslationBaseKey}.sun.description.rises`, - { hasDuration: duration !== "", duration: duration } + { hasDuration: duration !== "" ? "true" : "", duration: duration } ); } @@ -561,7 +561,7 @@ const tryDescribeTrigger = ( return hass.localize( `${triggerTranslationBaseKey}.template.description.full`, - { hasDuration: duration !== "", duration: duration } + { hasDuration: duration !== "" ? "true" : "", duration: duration } ); } diff --git a/src/data/script_i18n.ts b/src/data/script_i18n.ts index 09e25862b3cd..5bbf39ba9722 100644 --- a/src/data/script_i18n.ts +++ b/src/data/script_i18n.ts @@ -213,7 +213,7 @@ const tryDescribeAction = ( duration = hass.localize( `${actionTranslationBaseKey}.delay.description.duration_string`, { - string: formatDuration(config.delay), + string: formatDuration(config.delay)!, } ); } else { @@ -259,10 +259,15 @@ const tryDescribeAction = ( return hass.localize( `${actionTranslationBaseKey}.play_media.description.full`, { - hasMedia: config.metadata.title || config.data.media_content_id, - media: config.metadata.title || config.data.media_content_id, - hasMediaPlayer: mediaStateObj ? true : entityId !== undefined, - mediaPlayer: mediaStateObj ? computeStateName(mediaStateObj) : entityId, + hasMedia: + config.metadata.title || config.data.media_content_id ? "true" : "", + media: + (config.metadata.title as string | undefined) || + config.data.media_content_id, + hasMediaPlayer: mediaStateObj || entityId !== undefined ? "true" : "", + mediaPlayer: mediaStateObj + ? computeStateName(mediaStateObj) + : entityId!, } ); } @@ -317,7 +322,7 @@ const tryDescribeAction = ( if (actionType === "stop") { const config = action as StopAction; return hass.localize(`${actionTranslationBaseKey}.stop.description.full`, { - hasReason: config.stop !== undefined, + hasReason: config.stop !== undefined ? "true" : "", reason: config.stop, }); } diff --git a/src/dialogs/more-info/ha-more-info-info.ts b/src/dialogs/more-info/ha-more-info-info.ts index 1df9ef1401d3..7954e489284b 100644 --- a/src/dialogs/more-info/ha-more-info-info.ts +++ b/src/dialogs/more-info/ha-more-info-info.ts @@ -55,7 +55,7 @@ export class MoreInfoInfo extends LitElement { ${this.hass.localize( "ui.dialogs.more_info_control.restored.no_longer_provided", { - integration: entityRegObj.platform, + integration: entityRegObj.platform!, } )} ` diff --git a/src/dialogs/notifications/configurator-notification-item.ts b/src/dialogs/notifications/configurator-notification-item.ts index ae69269952d1..e5f163d32e29 100644 --- a/src/dialogs/notifications/configurator-notification-item.ts +++ b/src/dialogs/notifications/configurator-notification-item.ts @@ -26,7 +26,7 @@ export class HuiConfiguratorNotificationItem extends LitElement {
${this.hass.localize("ui.notification_drawer.click_to_configure", { - entity: this.notification.attributes.friendly_name, + entity: this.notification.attributes.friendly_name!, })}
diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index f3b8b0690063..acec8d6102db 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -672,7 +672,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { ), text: this.hass.localize( "ui.panel.config.automation.picker.delete_confirm_text", - { name: this._config?.alias } + { name: this._config!.alias! } ), confirmText: this.hass!.localize("ui.common.delete"), destructive: true, diff --git a/src/panels/config/integrations/ha-disabled-config-entry-card.ts b/src/panels/config/integrations/ha-disabled-config-entry-card.ts index f6003515aead..49b285ab3b4f 100644 --- a/src/panels/config/integrations/ha-disabled-config-entry-card.ts +++ b/src/panels/config/integrations/ha-disabled-config-entry-card.ts @@ -32,7 +32,7 @@ export class HaDisabledConfigEntryCard extends LitElement { this.hass.localize( `ui.panel.config.integrations.config_entry.disable.disabled_by.${this .entry.disabled_by!}` - ) || this.entry.disabled_by, + ) || this.entry.disabled_by!, } )} .domain=${this.entry.domain} diff --git a/src/panels/config/logs/error-log-card.ts b/src/panels/config/logs/error-log-card.ts index 3e688149cc9c..b127edeaa096 100644 --- a/src/panels/config/logs/error-log-card.ts +++ b/src/panels/config/logs/error-log-card.ts @@ -179,8 +179,7 @@ class ErrorLogCard extends LitElement { } catch (err: any) { this._error = this.hass.localize( "ui.panel.config.logs.failed_get_logs", - {provider:this.provider, - error:extractApiErrorMessage(err)} + { provider: this.provider, error: extractApiErrorMessage(err) } ); return; } diff --git a/src/panels/config/repairs/ha-config-repairs.ts b/src/panels/config/repairs/ha-config-repairs.ts index 1643de6b06a0..1a17b8caec9e 100644 --- a/src/panels/config/repairs/ha-config-repairs.ts +++ b/src/panels/config/repairs/ha-config-repairs.ts @@ -92,7 +92,7 @@ class HaConfigRepairs extends LitElement { ${issue.ignored ? ` - ${this.hass.localize( "ui.panel.config.repairs.dialog.ignored_in_version_short", - { version: issue.dismissed_version } + { version: issue.dismissed_version! } )}` : ""} diff --git a/src/panels/config/scene/ha-scene-editor.ts b/src/panels/config/scene/ha-scene-editor.ts index 816b63100156..8631569b2201 100644 --- a/src/panels/config/scene/ha-scene-editor.ts +++ b/src/panels/config/scene/ha-scene-editor.ts @@ -768,7 +768,7 @@ export class HaSceneEditor extends SubscribeMixin( ), text: this.hass!.localize( "ui.panel.config.scene.picker.delete_confirm_text", - { name: this._config?.name } + { name: this._config!.name } ), confirmText: this.hass!.localize("ui.common.delete"), dismissText: this.hass!.localize("ui.common.cancel"), diff --git a/src/panels/config/script/ha-script-editor.ts b/src/panels/config/script/ha-script-editor.ts index 1ed7527f3ca5..0fe53de70957 100644 --- a/src/panels/config/script/ha-script-editor.ts +++ b/src/panels/config/script/ha-script-editor.ts @@ -779,7 +779,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { ), text: this.hass.localize( "ui.panel.config.script.editor.delete_confirm_text", - { name: this._config?.alias } + { name: this._config!.alias } ), confirmText: this.hass!.localize("ui.common.delete"), dismissText: this.hass!.localize("ui.common.cancel"), diff --git a/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts index 3a67549e4f10..22b76a72232d 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts @@ -254,7 +254,7 @@ export class HuiEnergyGasGraphCard return [ this.hass.localize( "ui.panel.lovelace.cards.energy.energy_gas_graph.total_consumed", - { num: formatNumber(total, locale), unit } + { num: formatNumber(total, locale), unit: unit! } ), ]; }, diff --git a/src/panels/lovelace/cards/energy/hui-energy-water-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-water-graph-card.ts index 4fc102ebf2a9..3fd779143729 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-water-graph-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-water-graph-card.ts @@ -254,7 +254,7 @@ export class HuiEnergyWaterGraphCard return [ this.hass.localize( "ui.panel.lovelace.cards.energy.energy_water_graph.total_consumed", - { num: formatNumber(total, locale), unit } + { num: formatNumber(total, locale), unit: unit! } ), ]; }, diff --git a/src/panels/profile/ha-refresh-tokens-card.ts b/src/panels/profile/ha-refresh-tokens-card.ts index 6217936dcb46..24df4c7f738e 100644 --- a/src/panels/profile/ha-refresh-tokens-card.ts +++ b/src/panels/profile/ha-refresh-tokens-card.ts @@ -70,7 +70,7 @@ class HaRefreshTokens extends LitElement { )}
- ${token.last_used_at + ${token.last_used_at && token.last_used_ip ? this.hass.localize( "ui.panel.profile.refresh_tokens.last_used", { From fa72637635a685efe6473ade4cc525e6829d631f Mon Sep 17 00:00:00 2001 From: Kendell R Date: Tue, 26 Sep 2023 06:20:46 -0700 Subject: [PATCH 04/12] use switch again --- .../core/ha-config-system-navigation.ts | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/src/panels/config/core/ha-config-system-navigation.ts b/src/panels/config/core/ha-config-system-navigation.ts index 821d3479b106..75e91a657c58 100644 --- a/src/panels/config/core/ha-config-system-navigation.ts +++ b/src/panels/config/core/ha-config-system-navigation.ts @@ -50,9 +50,11 @@ class HaConfigSystemNavigation extends LitElement { const pages = configSections.general .filter((page) => canShowPage(this.hass, page)) .map((page) => { - const description = - page.translationKey === "backup" - ? this._latestBackupDate + let description = ""; + + switch (page.translationKey) { + case "backup": + description = this._latestBackupDate ? this.hass.localize("ui.panel.config.backup.description", { relative_time: relativeTime( new Date(this._latestBackupDate), @@ -61,28 +63,40 @@ class HaConfigSystemNavigation extends LitElement { }) : this.hass.localize( "ui.panel.config.backup.description_no_backup" - ) - : page.translationKey === "network" - ? this.hass.localize("ui.panel.config.network.description", { + ); + break; + case "network": + description = this.hass.localize( + "ui.panel.config.network.description", + { state: this._externalAccess ? this.hass.localize("ui.panel.config.network.enabled") : this.hass.localize("ui.panel.config.network.disabled"), - }) - : page.translationKey === "storage" - ? this._storageInfo + } + ); + break; + case "storage": + description = this._storageInfo ? this.hass.localize("ui.panel.config.storage.description", { percent_used: `${Math.round( (this._storageInfo.used / this._storageInfo.total) * 100 )}${blankBeforePercent(this.hass.locale)}%`, free_space: `${this._storageInfo.free} GB`, }) - : "" - : page.translationKey === "hardware" - ? this._boardName || - this.hass.localize("ui.panel.config.hardware.description") - : this.hass.localize( - `ui.panel.config.${page.translationKey}.description` - ); + : ""; + break; + case "hardware": + description = + this._boardName || + this.hass.localize("ui.panel.config.hardware.description"); + break; + + default: + description = this.hass.localize( + `ui.panel.config.${page.translationKey}.description` + ); + break; + } return { ...page, @@ -163,8 +177,9 @@ class HaConfigSystemNavigation extends LitElement { const hardwareInfo: HardwareInfo = await this.hass.callWS({ type: "hardware/info", }); - this._boardName = hardwareInfo?.hardware.find((hw) => hw.board !== null) - ?.name; + this._boardName = hardwareInfo?.hardware.find( + (hw) => hw.board !== null + )?.name; } else if (isHassioLoaded) { const osData: HassioHassOSInfo = await fetchHassioHassOsInfo(this.hass); if (osData.board) { From f6e9bd58802c810f37f83c57b7cc1614761ad84f Mon Sep 17 00:00:00 2001 From: Kendell R Date: Tue, 26 Sep 2023 06:27:30 -0700 Subject: [PATCH 05/12] format --- src/panels/config/core/ha-config-system-navigation.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/panels/config/core/ha-config-system-navigation.ts b/src/panels/config/core/ha-config-system-navigation.ts index 75e91a657c58..8c9493ec9046 100644 --- a/src/panels/config/core/ha-config-system-navigation.ts +++ b/src/panels/config/core/ha-config-system-navigation.ts @@ -177,9 +177,8 @@ class HaConfigSystemNavigation extends LitElement { const hardwareInfo: HardwareInfo = await this.hass.callWS({ type: "hardware/info", }); - this._boardName = hardwareInfo?.hardware.find( - (hw) => hw.board !== null - )?.name; + this._boardName = hardwareInfo?.hardware.find((hw) => hw.board !== null) + ?.name; } else if (isHassioLoaded) { const osData: HassioHassOSInfo = await fetchHassioHassOsInfo(this.hass); if (osData.board) { From 1cebdef90563c3f1381bde0001902ae40dfc1507 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Wed, 27 Sep 2023 19:56:38 -0700 Subject: [PATCH 06/12] Update warning to link to developers info page --- src/common/translations/localize.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/translations/localize.ts b/src/common/translations/localize.ts index 8cff8c6c58ff..0de715617ea4 100644 --- a/src/common/translations/localize.ts +++ b/src/common/translations/localize.ts @@ -104,11 +104,11 @@ export const computeLocalize = async ( argObject = args[0]; if (Object.values(argObject).some((v) => v === undefined)) { // eslint-disable-next-line no-console - console.warn("[FIXME] While localizing", key, "undefined was passed"); + console.warn("[FIXME] While localizing", key, "undefined was passed. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info."); } } else if (args.length >= 2) { // eslint-disable-next-line no-console - console.warn("[FIXME] While localizing", key, "old format was passed"); + console.warn("[FIXME] While localizing", key, "old format was passed. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info."); for (let i = 0; i < args.length; i += 2) { argObject[args[i]] = args[i + 1]; } From a6b32cf8dfc1315ea669b437bcb218121fb4eb8b Mon Sep 17 00:00:00 2001 From: Kendell R Date: Wed, 27 Sep 2023 19:59:57 -0700 Subject: [PATCH 07/12] Fix another usage of localize --- src/panels/developer-tools/service/developer-tools-service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/panels/developer-tools/service/developer-tools-service.ts b/src/panels/developer-tools/service/developer-tools-service.ts index ea740acfe599..aded6fedb371 100644 --- a/src/panels/developer-tools/service/developer-tools-service.ts +++ b/src/panels/developer-tools/service/developer-tools-service.ts @@ -332,8 +332,7 @@ class HaPanelDevService extends LitElement { ) { return localize( `ui.panel.developer-tools.tabs.services.errors.${errorCategory}.missing_required_field`, - "key", - field.key + { key: field.key } ); } } From 934e4864bfe90f905a9b3ca2dd0c85c651583387 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Wed, 27 Sep 2023 20:06:21 -0700 Subject: [PATCH 08/12] Run Prettier --- src/common/translations/localize.ts | 12 ++++++++++-- .../service/developer-tools-service.ts | 10 +++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/common/translations/localize.ts b/src/common/translations/localize.ts index 0de715617ea4..6211c65d80ca 100644 --- a/src/common/translations/localize.ts +++ b/src/common/translations/localize.ts @@ -104,11 +104,19 @@ export const computeLocalize = async ( argObject = args[0]; if (Object.values(argObject).some((v) => v === undefined)) { // eslint-disable-next-line no-console - console.warn("[FIXME] While localizing", key, "undefined was passed. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info."); + console.warn( + "[FIXME] While localizing", + key, + "undefined was passed. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info." + ); } } else if (args.length >= 2) { // eslint-disable-next-line no-console - console.warn("[FIXME] While localizing", key, "old format was passed. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info."); + console.warn( + "[FIXME] While localizing", + key, + "old format was passed. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info." + ); for (let i = 0; i < args.length; i += 2) { argObject[args[i]] = args[i + 1]; } diff --git a/src/panels/developer-tools/service/developer-tools-service.ts b/src/panels/developer-tools/service/developer-tools-service.ts index aded6fedb371..539aa5548e75 100644 --- a/src/panels/developer-tools/service/developer-tools-service.ts +++ b/src/panels/developer-tools/service/developer-tools-service.ts @@ -74,8 +74,8 @@ class HaPanelDevService extends LitElement { data: {}, }; if (this._yamlMode) { - this.updateComplete.then( - () => this._yamlEditor?.setValue(this._serviceData) + this.updateComplete.then(() => + this._yamlEditor?.setValue(this._serviceData) ); } } else if (!this._serviceData?.service) { @@ -87,8 +87,8 @@ class HaPanelDevService extends LitElement { data: {}, }; if (this._yamlMode) { - this.updateComplete.then( - () => this._yamlEditor?.setValue(this._serviceData) + this.updateComplete.then(() => + this._yamlEditor?.setValue(this._serviceData) ); } } @@ -426,7 +426,7 @@ class HaPanelDevService extends LitElement { button.actionError(); this._error = this.hass.localize("ui.notification_toast.service_call_failed", { - service: this._serviceData!.service! + service: this._serviceData!.service!, }) + ` ${err.message}`; return; } From 708234632d7169ad82c00d37f7e7c7d57d79a58c Mon Sep 17 00:00:00 2001 From: Kendell R Date: Thu, 28 Sep 2023 06:37:14 -0700 Subject: [PATCH 09/12] run prettier, update wording for bram --- src/common/translations/localize.ts | 18 +++++++++--------- .../service/developer-tools-service.ts | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/common/translations/localize.ts b/src/common/translations/localize.ts index 6211c65d80ca..52fb23795685 100644 --- a/src/common/translations/localize.ts +++ b/src/common/translations/localize.ts @@ -102,25 +102,25 @@ export const computeLocalize = async ( const args = _args as any; if (args.length === 1 && typeof args[0] === "object") { argObject = args[0]; - if (Object.values(argObject).some((v) => v === undefined)) { - // eslint-disable-next-line no-console - console.warn( - "[FIXME] While localizing", - key, - "undefined was passed. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info." - ); - } } else if (args.length >= 2) { // eslint-disable-next-line no-console console.warn( "[FIXME] While localizing", key, - "old format was passed. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info." + "the old format for parameters was used. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info." ); for (let i = 0; i < args.length; i += 2) { argObject[args[i]] = args[i + 1]; } } + if (Object.values(argObject).some((v) => v === undefined)) { + // eslint-disable-next-line no-console + console.warn( + "[FIXME] While localizing", + key, + "one of the parameters was undefined. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info." + ); + } try { return translatedMessage.format(argObject) as string; diff --git a/src/panels/developer-tools/service/developer-tools-service.ts b/src/panels/developer-tools/service/developer-tools-service.ts index 539aa5548e75..1faba95ee54f 100644 --- a/src/panels/developer-tools/service/developer-tools-service.ts +++ b/src/panels/developer-tools/service/developer-tools-service.ts @@ -74,8 +74,8 @@ class HaPanelDevService extends LitElement { data: {}, }; if (this._yamlMode) { - this.updateComplete.then(() => - this._yamlEditor?.setValue(this._serviceData) + this.updateComplete.then( + () => this._yamlEditor?.setValue(this._serviceData) ); } } else if (!this._serviceData?.service) { @@ -87,8 +87,8 @@ class HaPanelDevService extends LitElement { data: {}, }; if (this._yamlMode) { - this.updateComplete.then(() => - this._yamlEditor?.setValue(this._serviceData) + this.updateComplete.then( + () => this._yamlEditor?.setValue(this._serviceData) ); } } From 86dd0245178bcee620038acb667fff1cfe8cd2c7 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Thu, 28 Sep 2023 06:51:29 -0700 Subject: [PATCH 10/12] stricter type defs for recently added changes --- src/data/automation_i18n.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/data/automation_i18n.ts b/src/data/automation_i18n.ts index 1e8122a6e639..c1eef7170f5c 100644 --- a/src/data/automation_i18n.ts +++ b/src/data/automation_i18n.ts @@ -156,11 +156,11 @@ const tryDescribeTrigger = ( return hass.localize( `${triggerTranslationBaseKey}.numeric_state.description.above-below`, { - attribute: attribute, + attribute: attribute === undefined ? "undefined" : attribute, entity: entity, above: trigger.above, below: trigger.below, - duration: duration, + duration: duration == null ? "undefined" : duration, } ); } @@ -168,10 +168,10 @@ const tryDescribeTrigger = ( return hass.localize( `${triggerTranslationBaseKey}.numeric_state.description.above`, { - attribute: attribute, + attribute: attribute === undefined ? "undefined" : attribute, entity: entity, above: trigger.above, - duration: duration, + duration: duration == null ? "undefined" : duration, } ); } @@ -179,10 +179,10 @@ const tryDescribeTrigger = ( return hass.localize( `${triggerTranslationBaseKey}.numeric_state.description.below`, { - attribute: attribute, + attribute: attribute === undefined ? "undefined" : attribute, entity: entity, below: trigger.below, - duration: duration, + duration: duration == null ? "undefined" : duration, } ); } @@ -854,7 +854,7 @@ const tryDescribeCondition = ( return hass.localize( `${conditionsTranslationBaseKey}.numeric_state.description.above-below`, { - attribute: attribute, + attribute: attribute === undefined ? "undefined" : attribute, entity: entity, above: condition.above, below: condition.below, @@ -865,7 +865,7 @@ const tryDescribeCondition = ( return hass.localize( `${conditionsTranslationBaseKey}.numeric_state.description.above`, { - attribute: attribute, + attribute: attribute === undefined ? "undefined" : attribute, entity: entity, above: condition.above, } @@ -875,7 +875,7 @@ const tryDescribeCondition = ( return hass.localize( `${conditionsTranslationBaseKey}.numeric_state.description.below`, { - attribute: attribute, + attribute: attribute === undefined ? "undefined" : attribute, entity: entity, below: condition.below, } From d52c513b96c4ad9bde157a9dc963e9504120e3e1 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Thu, 28 Sep 2023 16:19:58 -0700 Subject: [PATCH 11/12] Update warnings --- src/common/translations/localize.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/common/translations/localize.ts b/src/common/translations/localize.ts index 52fb23795685..406f375389d9 100644 --- a/src/common/translations/localize.ts +++ b/src/common/translations/localize.ts @@ -105,20 +105,16 @@ export const computeLocalize = async ( } else if (args.length >= 2) { // eslint-disable-next-line no-console console.warn( - "[FIXME] While localizing", - key, - "the old format for parameters was used. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info." + `hass.localize for the key "${key}" was invoked using the deprecated arguments format. For more info and guidelines on updating usage, please visit https://developers.home-assistant.io/blog/2023/09/27/localize-handling.` ); for (let i = 0; i < args.length; i += 2) { argObject[args[i]] = args[i + 1]; } } - if (Object.values(argObject).some((v) => v === undefined)) { + if (Object.values(argObject).some((v) => v == null)) { // eslint-disable-next-line no-console - console.warn( - "[FIXME] While localizing", - key, - "one of the parameters was undefined. See https://developers.home-assistant.io/blog/2023/09/27/localize-handling for more info." + console.error( + `hass.localize for the key "${key}" was invoked with an undefined parameter. For more info about what this means, please visit https://developers.home-assistant.io/blog/2023/09/27/localize-handling.` ); } From 641b29cbfe183d99038eb217aeb4ec97bbbeb305 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Thu, 28 Sep 2023 19:58:33 -0700 Subject: [PATCH 12/12] Update wording per review Co-authored-by: Steve Repsher --- src/common/translations/localize.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/translations/localize.ts b/src/common/translations/localize.ts index 406f375389d9..d013e2c1df4b 100644 --- a/src/common/translations/localize.ts +++ b/src/common/translations/localize.ts @@ -105,7 +105,7 @@ export const computeLocalize = async ( } else if (args.length >= 2) { // eslint-disable-next-line no-console console.warn( - `hass.localize for the key "${key}" was invoked using the deprecated arguments format. For more info and guidelines on updating usage, please visit https://developers.home-assistant.io/blog/2023/09/27/localize-handling.` + `Localization for the key "${key}" was performed using the deprecated arguments format. For more info and guidelines on updating usage, please visit https://developers.home-assistant.io/blog/2023/09/27/localize-handling.` ); for (let i = 0; i < args.length; i += 2) { argObject[args[i]] = args[i + 1]; @@ -114,7 +114,7 @@ export const computeLocalize = async ( if (Object.values(argObject).some((v) => v == null)) { // eslint-disable-next-line no-console console.error( - `hass.localize for the key "${key}" was invoked with an undefined parameter. For more info about what this means, please visit https://developers.home-assistant.io/blog/2023/09/27/localize-handling.` + `Localization for the key "${key}" was performed with an undefined parameter. For more info about what this means, please visit https://developers.home-assistant.io/blog/2023/09/27/localize-handling.` ); }