Skip to content

Commit

Permalink
Load translations on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
jbouwh committed Nov 1, 2023
1 parent 2366db9 commit 876f3a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/layouts/home-assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
12 changes: 9 additions & 3 deletions src/state/connection-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,16 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
}
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(
Expand Down

0 comments on commit 876f3a1

Please sign in to comment.