Skip to content

Commit 2e7c95a

Browse files
authored
Translate dashboard panel url error message (#27306)
* Translate dashboard panel url error message * Use backend provided translations
1 parent 9630b17 commit 2e7c95a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/panels/config/lovelace/dashboards/dialog-lovelace-dashboard-detail.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,20 @@ export class DialogLovelaceDashboardDetail extends LitElement {
309309
}
310310
this.closeDialog();
311311
} catch (err: any) {
312-
this._error = { base: err?.message || "Unknown error" };
312+
let localizedErrorMessage: string | undefined;
313+
if (err?.translation_domain && err?.translation_key) {
314+
const localize = await this.hass.loadBackendTranslation(
315+
"exceptions",
316+
err.translation_domain
317+
);
318+
localizedErrorMessage = localize(
319+
`component.${err.translation_domain}.exceptions.${err.translation_key}.message`,
320+
err.translation_placeholders
321+
);
322+
}
323+
this._error = {
324+
base: localizedErrorMessage || err?.message || "Unknown error",
325+
};
313326
} finally {
314327
this._submitting = false;
315328
}

0 commit comments

Comments
 (0)