From 43c2c5e7d7ae3551419fe0b18b289a0fee74c04f Mon Sep 17 00:00:00 2001 From: jbouwh Date: Wed, 1 Nov 2023 17:40:07 +0000 Subject: [PATCH] Load translations on demand --- src/layouts/home-assistant.ts | 3 --- src/state/connection-mixin.ts | 6 +++++- 2 files changed, 5 insertions(+), 4 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..f5eae4519162 100644 --- a/src/state/connection-mixin.ts +++ b/src/state/connection-mixin.ts @@ -122,7 +122,11 @@ export const connectionMixin = >( } if (notifyOnError) { forwardHaptic("failure"); - const localizedErrorMessage = (this as any).hass.localize( + const lokalize = await (this as any).loadBackendTranslation( + "exceptions", + domain + ); + const localizedErrorMessage = lokalize( `component.${err.translation_domain}.exceptions.${err.translation_key}.message`, err.translation_placeholders );