diff --git a/src/data/translation.ts b/src/data/translation.ts index bc8165578a99..e4824b0e636f 100644 --- a/src/data/translation.ts +++ b/src/data/translation.ts @@ -61,6 +61,7 @@ export type TranslationCategory = | "state" | "entity" | "entity_component" + | "exceptions" | "config" | "config_panel" | "options" diff --git a/src/layouts/home-assistant.ts b/src/layouts/home-assistant.ts index f9781eef5db5..f955793a3a75 100644 --- a/src/layouts/home-assistant.ts +++ b/src/layouts/home-assistant.ts @@ -173,6 +173,9 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) { // @ts-ignore this._loadHassTranslations(this.hass!.language, "state"); + // @ts-ignore + this._loadHassTranslations(this.hass!.language, "exceptions"); + document.addEventListener( "visibilitychange", () => this._checkVisibility(), diff --git a/src/state/connection-mixin.ts b/src/state/connection-mixin.ts index 08113c821a2c..b879e0ac8af7 100644 --- a/src/state/connection-mixin.ts +++ b/src/state/connection-mixin.ts @@ -122,6 +122,10 @@ export const connectionMixin = >( } if (notifyOnError) { forwardHaptic("failure"); + const lokalizedErrorMessage = (this as any).hass.localize( + `component.${err.translation_domain}.exceptions.${err.translation_key}.message`, + err.translation_placeholders + ); const message = (this as any).hass.localize( "ui.notification_toast.service_call_failed", @@ -129,6 +133,7 @@ export const connectionMixin = >( `${domain}/${service}` ) + ` ${ + lokalizedErrorMessage || err.message || (err.error?.code === ERR_CONNECTION_LOST ? "connection lost"