Translate dashboard panel url error message (#27306)

* Translate dashboard panel url error message

* Use backend provided translations
This commit is contained in:
steinmn 2025-11-23 14:54:21 +01:00 committed by GitHub
parent 9630b175a1
commit 2e7c95a8cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -309,7 +309,20 @@ export class DialogLovelaceDashboardDetail extends LitElement {
}
this.closeDialog();
} catch (err: any) {
this._error = { base: err?.message || "Unknown error" };
let localizedErrorMessage: string | undefined;
if (err?.translation_domain && err?.translation_key) {
const localize = await this.hass.loadBackendTranslation(
"exceptions",
err.translation_domain
);
localizedErrorMessage = localize(
`component.${err.translation_domain}.exceptions.${err.translation_key}.message`,
err.translation_placeholders
);
}
this._error = {
base: localizedErrorMessage || err?.message || "Unknown error",
};
} finally {
this._submitting = false;
}