From 0a799f857e17f9467ba31061e44e45018c94ddb3 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Mon, 8 Jul 2024 13:45:16 +0200 Subject: [PATCH] Use localize func in table settings dialog --- .../data-table/dialog-data-table-settings.ts | 10 +++++----- .../data-table/show-dialog-data-table-settings.ts | 2 ++ src/layouts/hass-tabs-subpage-data-table.ts | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/data-table/dialog-data-table-settings.ts b/src/components/data-table/dialog-data-table-settings.ts index 1dfe8bbabf49..dd8a6f28888c 100644 --- a/src/components/data-table/dialog-data-table-settings.ts +++ b/src/components/data-table/dialog-data-table-settings.ts @@ -78,6 +78,8 @@ export class DialogDataTableSettings extends LitElement { return nothing; } + const localize = this._params.localizeFunc || this.hass.localize; + const columns = this._sortedColumns( this._params.columns, this._columnOrder, @@ -90,7 +92,7 @@ export class DialogDataTableSettings extends LitElement { @closed=${this.closeDialog} .heading=${createCloseHeading( this.hass, - this.hass.localize("ui.components.data-table.settings.header") + localize("ui.components.data-table.settings.header") )} > ${this.hass.localize( - "ui.components.data-table.settings.restore" - )}${localize("ui.components.data-table.settings.restore")} - ${this.hass.localize("ui.components.data-table.settings.done")} + ${localize("ui.components.data-table.settings.done")} `; diff --git a/src/components/data-table/show-dialog-data-table-settings.ts b/src/components/data-table/show-dialog-data-table-settings.ts index b31e801acb11..954dd871bb26 100644 --- a/src/components/data-table/show-dialog-data-table-settings.ts +++ b/src/components/data-table/show-dialog-data-table-settings.ts @@ -1,4 +1,5 @@ import { fireEvent } from "../../common/dom/fire_event"; +import { LocalizeFunc } from "../../common/translations/localize"; import { DataTableColumnContainer } from "./ha-data-table"; export interface DataTableSettingsDialogParams { @@ -9,6 +10,7 @@ export interface DataTableSettingsDialogParams { ) => void; hiddenColumns?: string[]; columnOrder?: string[]; + localizeFunc?: LocalizeFunc; } export const loadDataTableSettingsDialog = () => diff --git a/src/layouts/hass-tabs-subpage-data-table.ts b/src/layouts/hass-tabs-subpage-data-table.ts index 615fb2d5d056..79db1674e59a 100644 --- a/src/layouts/hass-tabs-subpage-data-table.ts +++ b/src/layouts/hass-tabs-subpage-data-table.ts @@ -638,6 +638,7 @@ export class HaTabsSubpageDataTable extends LitElement { this.hiddenColumns = hiddenColumns; fireEvent(this, "columns-changed", { columnOrder, hiddenColumns }); }, + localizeFunc: this.localizeFunc, }); }