mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
Add translation to integration setup failures (#19128)
This commit is contained in:
parent
c7444a2605
commit
697bbf428e
@ -36,6 +36,8 @@ const createConfigEntry = (
|
|||||||
pref_disable_new_entities: false,
|
pref_disable_new_entities: false,
|
||||||
pref_disable_polling: false,
|
pref_disable_polling: false,
|
||||||
reason: null,
|
reason: null,
|
||||||
|
error_reason_translation_key: null,
|
||||||
|
error_reason_translation_placeholders: null,
|
||||||
...override,
|
...override,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ export interface ConfigEntry {
|
|||||||
pref_disable_polling: boolean;
|
pref_disable_polling: boolean;
|
||||||
disabled_by: "user" | null;
|
disabled_by: "user" | null;
|
||||||
reason: string | null;
|
reason: string | null;
|
||||||
|
error_reason_translation_key: string | null;
|
||||||
|
error_reason_translation_placeholders: Record<string, string> | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ConfigEntryMutableParams = Partial<
|
export type ConfigEntryMutableParams = Partial<
|
||||||
|
@ -37,6 +37,7 @@ import {
|
|||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
|
import { until } from "lit/directives/until";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
import { isDevVersion } from "../../../common/config/version";
|
import { isDevVersion } from "../../../common/config/version";
|
||||||
@ -550,10 +551,24 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
`ui.panel.config.integrations.config_entry.state.${item.state}`,
|
`ui.panel.config.integrations.config_entry.state.${item.state}`,
|
||||||
];
|
];
|
||||||
if (item.reason) {
|
if (item.reason) {
|
||||||
this.hass.loadBackendTranslation("config", item.domain);
|
if (item.error_reason_translation_key) {
|
||||||
stateTextExtra = html`${this.hass.localize(
|
const lokalisePromExc = this.hass
|
||||||
`component.${item.domain}.config.error.${item.reason}`
|
.loadBackendTranslation("exceptions", item.domain)
|
||||||
) || item.reason}`;
|
.then((localize) =>
|
||||||
|
localize(
|
||||||
|
`component.${item.domain}.exceptions.${item.error_reason_translation_key}.message`,
|
||||||
|
item.error_reason_translation_placeholders ?? undefined
|
||||||
|
)
|
||||||
|
);
|
||||||
|
stateTextExtra = html`${until(lokalisePromExc)}`;
|
||||||
|
} else {
|
||||||
|
const lokalisePromError = this.hass
|
||||||
|
.loadBackendTranslation("config", item.domain)
|
||||||
|
.then((localize) =>
|
||||||
|
localize(`component.${item.domain}.config.error.${item.reason}`)
|
||||||
|
);
|
||||||
|
stateTextExtra = html`${until(lokalisePromError, item.reason)}`;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
stateTextExtra = html`
|
stateTextExtra = html`
|
||||||
<br />
|
<br />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user