From 876f3a1440778eba42c636a7fffac40e57c26662 Mon Sep 17 00:00:00 2001 From: jbouwh Date: Wed, 1 Nov 2023 17:49:45 +0000 Subject: [PATCH] Load translations on demand --- src/layouts/home-assistant.ts | 3 --- src/state/connection-mixin.ts | 12 +++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/layouts/home-assistant.ts b/src/layouts/home-assistant.ts index f955793a3a75..f9781eef5db5 100644 --- a/src/layouts/home-assistant.ts +++ b/src/layouts/home-assistant.ts @@ -173,9 +173,6 @@ 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 cafc9cf46f04..e578f2b230e1 100644 --- a/src/state/connection-mixin.ts +++ b/src/state/connection-mixin.ts @@ -122,10 +122,16 @@ export const connectionMixin = >( } if (notifyOnError) { forwardHaptic("failure"); - const localizedErrorMessage = (this as any).hass.localize( - `component.${err.translation_domain}.exceptions.${err.translation_key}.message`, - err.translation_placeholders + const lokalize = await this.hass?.loadBackendTranslation( + "exceptions", + domain ); + const localizedErrorMessage = + lokalize && + lokalize( + `component.${err.translation_domain}.exceptions.${err.translation_key}.message`, + err.translation_placeholders + ); const message = localizedErrorMessage || (this as any).hass.localize(