Skip to content

Commit

Permalink
Use localize func in table settings dialog (#21335)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Jul 8, 2024
1 parent e7a749e commit c85e29f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/data-table/dialog-data-table-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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")
)}
>
<ha-sortable
Expand Down Expand Up @@ -146,12 +148,10 @@ export class DialogDataTableSettings extends LitElement {
</mwc-list>
</ha-sortable>
<ha-button slot="secondaryAction" @click=${this._reset}
>${this.hass.localize(
"ui.components.data-table.settings.restore"
)}</ha-button
>${localize("ui.components.data-table.settings.restore")}</ha-button
>
<ha-button slot="primaryAction" @click=${this.closeDialog}>
${this.hass.localize("ui.components.data-table.settings.done")}
${localize("ui.components.data-table.settings.done")}
</ha-button>
</ha-dialog>
`;
Expand Down
2 changes: 2 additions & 0 deletions src/components/data-table/show-dialog-data-table-settings.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -9,6 +10,7 @@ export interface DataTableSettingsDialogParams {
) => void;
hiddenColumns?: string[];
columnOrder?: string[];
localizeFunc?: LocalizeFunc;
}

export const loadDataTableSettingsDialog = () =>
Expand Down
1 change: 1 addition & 0 deletions src/layouts/hass-tabs-subpage-data-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ export class HaTabsSubpageDataTable extends LitElement {
this.hiddenColumns = hiddenColumns;
fireEvent(this, "columns-changed", { columnOrder, hiddenColumns });
},
localizeFunc: this.localizeFunc,
});
}

Expand Down

0 comments on commit c85e29f

Please sign in to comment.