mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-20 15:56:35 +00:00
Localization bugfixes in config devices/entities/helpers (#18645)
This commit is contained in:
parent
e2e80d1f49
commit
3addfc3548
@ -285,7 +285,8 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
private _columns = memoizeOne((narrow: boolean, showDisabled: boolean) => {
|
private _columns = memoizeOne(
|
||||||
|
(localize: LocalizeFunc, narrow: boolean, showDisabled: boolean) => {
|
||||||
type DeviceItem = ReturnType<
|
type DeviceItem = ReturnType<
|
||||||
typeof this._devicesAndFilterDomains
|
typeof this._devicesAndFilterDomains
|
||||||
>["devicesOutput"][number];
|
>["devicesOutput"][number];
|
||||||
@ -312,7 +313,7 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
|
|
||||||
if (narrow) {
|
if (narrow) {
|
||||||
columns.name = {
|
columns.name = {
|
||||||
title: this.hass.localize("ui.panel.config.devices.data_table.device"),
|
title: localize("ui.panel.config.devices.data_table.device"),
|
||||||
main: true,
|
main: true,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
@ -325,7 +326,7 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
columns.name = {
|
columns.name = {
|
||||||
title: this.hass.localize("ui.panel.config.devices.data_table.device"),
|
title: localize("ui.panel.config.devices.data_table.device"),
|
||||||
main: true,
|
main: true,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
@ -335,39 +336,35 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
columns.manufacturer = {
|
columns.manufacturer = {
|
||||||
title: this.hass.localize(
|
title: localize("ui.panel.config.devices.data_table.manufacturer"),
|
||||||
"ui.panel.config.devices.data_table.manufacturer"
|
|
||||||
),
|
|
||||||
sortable: true,
|
sortable: true,
|
||||||
hidden: narrow,
|
hidden: narrow,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
width: "15%",
|
width: "15%",
|
||||||
};
|
};
|
||||||
columns.model = {
|
columns.model = {
|
||||||
title: this.hass.localize("ui.panel.config.devices.data_table.model"),
|
title: localize("ui.panel.config.devices.data_table.model"),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
hidden: narrow,
|
hidden: narrow,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
width: "15%",
|
width: "15%",
|
||||||
};
|
};
|
||||||
columns.area = {
|
columns.area = {
|
||||||
title: this.hass.localize("ui.panel.config.devices.data_table.area"),
|
title: localize("ui.panel.config.devices.data_table.area"),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
hidden: narrow,
|
hidden: narrow,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
width: "15%",
|
width: "15%",
|
||||||
};
|
};
|
||||||
columns.integration = {
|
columns.integration = {
|
||||||
title: this.hass.localize(
|
title: localize("ui.panel.config.devices.data_table.integration"),
|
||||||
"ui.panel.config.devices.data_table.integration"
|
|
||||||
),
|
|
||||||
sortable: true,
|
sortable: true,
|
||||||
hidden: narrow,
|
hidden: narrow,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
width: "15%",
|
width: "15%",
|
||||||
};
|
};
|
||||||
columns.battery_entity = {
|
columns.battery_entity = {
|
||||||
title: this.hass.localize("ui.panel.config.devices.data_table.battery"),
|
title: localize("ui.panel.config.devices.data_table.battery"),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
type: "numeric",
|
type: "numeric",
|
||||||
@ -380,7 +377,9 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
batteryEntityPair && batteryEntityPair[0]
|
batteryEntityPair && batteryEntityPair[0]
|
||||||
? this.hass.states[batteryEntityPair[0]]
|
? this.hass.states[batteryEntityPair[0]]
|
||||||
: undefined;
|
: undefined;
|
||||||
const batteryDomain = battery ? computeStateDomain(battery) : undefined;
|
const batteryDomain = battery
|
||||||
|
? computeStateDomain(battery)
|
||||||
|
: undefined;
|
||||||
const batteryCharging =
|
const batteryCharging =
|
||||||
batteryEntityPair && batteryEntityPair[1]
|
batteryEntityPair && batteryEntityPair[1]
|
||||||
? this.hass.states[batteryEntityPair[1]]
|
? this.hass.states[batteryEntityPair[1]]
|
||||||
@ -404,9 +403,7 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
if (showDisabled) {
|
if (showDisabled) {
|
||||||
columns.disabled_by = {
|
columns.disabled_by = {
|
||||||
title: "",
|
title: "",
|
||||||
label: this.hass.localize(
|
label: localize("ui.panel.config.devices.data_table.disabled_by"),
|
||||||
"ui.panel.config.devices.data_table.disabled_by"
|
|
||||||
),
|
|
||||||
type: "icon",
|
type: "icon",
|
||||||
template: (device) =>
|
template: (device) =>
|
||||||
device.disabled_by
|
device.disabled_by
|
||||||
@ -423,7 +420,8 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return columns;
|
return columns;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
public willUpdate(changedProps) {
|
public willUpdate(changedProps) {
|
||||||
if (changedProps.has("_searchParms")) {
|
if (changedProps.has("_searchParms")) {
|
||||||
@ -474,7 +472,11 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
"number",
|
"number",
|
||||||
this._numHiddenDevices
|
this._numHiddenDevices
|
||||||
)}
|
)}
|
||||||
.columns=${this._columns(this.narrow, this._showDisabled)}
|
.columns=${this._columns(
|
||||||
|
this.hass.localize,
|
||||||
|
this.narrow,
|
||||||
|
this._showDisabled
|
||||||
|
)}
|
||||||
.data=${devicesOutput}
|
.data=${devicesOutput}
|
||||||
.filter=${this._filter}
|
.filter=${this._filter}
|
||||||
@clear-filter=${this._clearFilter}
|
@clear-filter=${this._clearFilter}
|
||||||
|
@ -84,6 +84,7 @@ export interface EntityRow extends StateEntity {
|
|||||||
restored: boolean;
|
restored: boolean;
|
||||||
status: string;
|
status: string;
|
||||||
area?: string;
|
area?: string;
|
||||||
|
localized_platform: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@customElement("ha-config-entities")
|
@customElement("ha-config-entities")
|
||||||
@ -176,12 +177,15 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private _columns = memoize(
|
private _columns = memoize(
|
||||||
(narrow, _language, showDisabled): DataTableColumnContainer<EntityRow> => ({
|
(
|
||||||
|
localize: LocalizeFunc,
|
||||||
|
narrow,
|
||||||
|
_language,
|
||||||
|
showDisabled
|
||||||
|
): DataTableColumnContainer<EntityRow> => ({
|
||||||
icon: {
|
icon: {
|
||||||
title: "",
|
title: "",
|
||||||
label: this.hass.localize(
|
label: localize("ui.panel.config.entities.picker.headers.state_icon"),
|
||||||
"ui.panel.config.entities.picker.headers.state_icon"
|
|
||||||
),
|
|
||||||
type: "icon",
|
type: "icon",
|
||||||
template: (entry) => html`
|
template: (entry) => html`
|
||||||
<ha-state-icon
|
<ha-state-icon
|
||||||
@ -193,9 +197,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
main: true,
|
main: true,
|
||||||
title: this.hass.localize(
|
title: localize("ui.panel.config.entities.picker.headers.name"),
|
||||||
"ui.panel.config.entities.picker.headers.name"
|
|
||||||
),
|
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
direction: "asc",
|
direction: "asc",
|
||||||
@ -204,47 +206,34 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
? (entry) => html`
|
? (entry) => html`
|
||||||
${entry.name}<br />
|
${entry.name}<br />
|
||||||
<div class="secondary">
|
<div class="secondary">
|
||||||
${entry.entity_id} |
|
${entry.entity_id} | ${entry.localized_platform}
|
||||||
${this.hass.localize(`component.${entry.platform}.title`) ||
|
|
||||||
entry.platform}
|
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: undefined,
|
: undefined,
|
||||||
},
|
},
|
||||||
entity_id: {
|
entity_id: {
|
||||||
title: this.hass.localize(
|
title: localize("ui.panel.config.entities.picker.headers.entity_id"),
|
||||||
"ui.panel.config.entities.picker.headers.entity_id"
|
|
||||||
),
|
|
||||||
hidden: narrow,
|
hidden: narrow,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
width: "25%",
|
width: "25%",
|
||||||
},
|
},
|
||||||
platform: {
|
localized_platform: {
|
||||||
title: this.hass.localize(
|
title: localize("ui.panel.config.entities.picker.headers.integration"),
|
||||||
"ui.panel.config.entities.picker.headers.integration"
|
|
||||||
),
|
|
||||||
hidden: narrow,
|
hidden: narrow,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
width: "20%",
|
width: "20%",
|
||||||
template: (entry) =>
|
|
||||||
this.hass.localize(`component.${entry.platform}.title`) ||
|
|
||||||
entry.platform,
|
|
||||||
},
|
},
|
||||||
area: {
|
area: {
|
||||||
title: this.hass.localize(
|
title: localize("ui.panel.config.entities.picker.headers.area"),
|
||||||
"ui.panel.config.entities.picker.headers.area"
|
|
||||||
),
|
|
||||||
sortable: true,
|
sortable: true,
|
||||||
hidden: narrow,
|
hidden: narrow,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
width: "15%",
|
width: "15%",
|
||||||
},
|
},
|
||||||
disabled_by: {
|
disabled_by: {
|
||||||
title: this.hass.localize(
|
title: localize("ui.panel.config.entities.picker.headers.disabled_by"),
|
||||||
"ui.panel.config.entities.picker.headers.disabled_by"
|
|
||||||
),
|
|
||||||
sortable: true,
|
sortable: true,
|
||||||
hidden: narrow || !showDisabled,
|
hidden: narrow || !showDisabled,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
@ -257,9 +246,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
title: this.hass.localize(
|
title: localize("ui.panel.config.entities.picker.headers.status"),
|
||||||
"ui.panel.config.entities.picker.headers.status"
|
|
||||||
),
|
|
||||||
type: "icon",
|
type: "icon",
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
@ -318,6 +305,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
private _filteredEntitiesAndDomains = memoize(
|
private _filteredEntitiesAndDomains = memoize(
|
||||||
(
|
(
|
||||||
|
localize: LocalizeFunc,
|
||||||
entities: StateEntity[],
|
entities: StateEntity[],
|
||||||
devices: DeviceRegistryEntry[] | undefined,
|
devices: DeviceRegistryEntry[] | undefined,
|
||||||
areas: AreaRegistryEntry[] | undefined,
|
areas: AreaRegistryEntry[] | undefined,
|
||||||
@ -432,20 +420,16 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
),
|
),
|
||||||
unavailable,
|
unavailable,
|
||||||
restored,
|
restored,
|
||||||
|
localized_platform:
|
||||||
|
localize(`component.${entry.platform}.title`) || entry.platform,
|
||||||
area: area ? area.name : "—",
|
area: area ? area.name : "—",
|
||||||
status: restored
|
status: restored
|
||||||
? this.hass.localize(
|
? localize("ui.panel.config.entities.picker.status.restored")
|
||||||
"ui.panel.config.entities.picker.status.restored"
|
|
||||||
)
|
|
||||||
: unavailable
|
: unavailable
|
||||||
? this.hass.localize(
|
? localize("ui.panel.config.entities.picker.status.unavailable")
|
||||||
"ui.panel.config.entities.picker.status.unavailable"
|
|
||||||
)
|
|
||||||
: entry.disabled_by
|
: entry.disabled_by
|
||||||
? this.hass.localize(
|
? localize("ui.panel.config.entities.picker.status.disabled")
|
||||||
"ui.panel.config.entities.picker.status.disabled"
|
: localize("ui.panel.config.entities.picker.status.ok"),
|
||||||
)
|
|
||||||
: this.hass.localize("ui.panel.config.entities.picker.status.ok"),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,6 +482,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
const { filteredEntities, filteredDomains } =
|
const { filteredEntities, filteredDomains } =
|
||||||
this._filteredEntitiesAndDomains(
|
this._filteredEntitiesAndDomains(
|
||||||
|
this.hass.localize,
|
||||||
this._entities,
|
this._entities,
|
||||||
this._devices,
|
this._devices,
|
||||||
this._areas,
|
this._areas,
|
||||||
@ -526,6 +511,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
.route=${this.route}
|
.route=${this.route}
|
||||||
.tabs=${configSections.devices}
|
.tabs=${configSections.devices}
|
||||||
.columns=${this._columns(
|
.columns=${this._columns(
|
||||||
|
this.hass.localize,
|
||||||
this.narrow,
|
this.narrow,
|
||||||
this.hass.language,
|
this.hass.language,
|
||||||
this._showDisabled
|
this._showDisabled
|
||||||
@ -969,6 +955,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
private _addDevice() {
|
private _addDevice() {
|
||||||
const { filteredConfigEntry, filteredDomains } =
|
const { filteredConfigEntry, filteredDomains } =
|
||||||
this._filteredEntitiesAndDomains(
|
this._filteredEntitiesAndDomains(
|
||||||
|
this.hass.localize,
|
||||||
this._entities!,
|
this._entities!,
|
||||||
this._devices,
|
this._devices,
|
||||||
this._areas,
|
this._areas,
|
||||||
|
@ -158,19 +158,11 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
width: "25%",
|
width: "25%",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
columns.type = {
|
columns.localized_type = {
|
||||||
title: localize("ui.panel.config.helpers.picker.headers.type"),
|
title: localize("ui.panel.config.helpers.picker.headers.type"),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
width: "25%",
|
width: "25%",
|
||||||
filterable: true,
|
filterable: true,
|
||||||
template: (helper) =>
|
|
||||||
helper.configEntry
|
|
||||||
? domainToName(localize, helper.type)
|
|
||||||
: html`
|
|
||||||
${localize(
|
|
||||||
`ui.panel.config.helpers.types.${helper.type}` as LocalizeKeys
|
|
||||||
) || helper.type}
|
|
||||||
`,
|
|
||||||
};
|
};
|
||||||
columns.editable = {
|
columns.editable = {
|
||||||
title: "",
|
title: "",
|
||||||
@ -202,6 +194,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
private _getItems = memoizeOne(
|
private _getItems = memoizeOne(
|
||||||
(
|
(
|
||||||
|
localize: LocalizeFunc,
|
||||||
stateItems: HassEntity[],
|
stateItems: HassEntity[],
|
||||||
entityEntries: Record<string, EntityRegistryEntry>,
|
entityEntries: Record<string, EntityRegistryEntry>,
|
||||||
configEntries: Record<string, ConfigEntry>
|
configEntries: Record<string, ConfigEntry>
|
||||||
@ -248,7 +241,14 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
entity: undefined,
|
entity: undefined,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return [...states, ...entries];
|
return [...states, ...entries].map((item) => ({
|
||||||
|
...item,
|
||||||
|
localized_type: item.configEntry
|
||||||
|
? domainToName(localize, item.type)
|
||||||
|
: localize(
|
||||||
|
`ui.panel.config.helpers.types.${item.type}` as LocalizeKeys
|
||||||
|
) || item.type,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -271,6 +271,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
.tabs=${configSections.devices}
|
.tabs=${configSections.devices}
|
||||||
.columns=${this._columns(this.narrow, this.hass.localize)}
|
.columns=${this._columns(this.narrow, this.hass.localize)}
|
||||||
.data=${this._getItems(
|
.data=${this._getItems(
|
||||||
|
this.hass.localize,
|
||||||
this._stateItems,
|
this._stateItems,
|
||||||
this._entityEntries,
|
this._entityEntries,
|
||||||
this._configEntries
|
this._configEntries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user