mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-08 10:29:37 +00:00
Adjust backend translations for entity components (#15820)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
@@ -12,6 +12,7 @@ export const computeAttributeValueDisplay = (
|
||||
value?: any
|
||||
): string => {
|
||||
const entityId = stateObj.entity_id;
|
||||
const deviceClass = stateObj.attributes.device_class;
|
||||
const attributeValue =
|
||||
value !== undefined ? value : stateObj.attributes[attribute];
|
||||
const domain = computeDomain(entityId);
|
||||
@@ -23,8 +24,12 @@ export const computeAttributeValueDisplay = (
|
||||
localize(
|
||||
`component.${entity.platform}.entity.${domain}.${translationKey}.state_attributes.${attribute}.state.${attributeValue}`
|
||||
)) ||
|
||||
(deviceClass &&
|
||||
localize(
|
||||
`component.${domain}.entity_component.${deviceClass}.state_attributes.${attribute}.state.${attributeValue}`
|
||||
)) ||
|
||||
localize(
|
||||
`component.${domain}.state_attributes._.${attribute}.state.${attributeValue}`
|
||||
`component.${domain}.entity_component._.state_attributes.${attribute}.state.${attributeValue}`
|
||||
) ||
|
||||
attributeValue
|
||||
);
|
||||
@@ -37,6 +42,7 @@ export const computeAttributeNameDisplay = (
|
||||
attribute: string
|
||||
): string => {
|
||||
const entityId = stateObj.entity_id;
|
||||
const deviceClass = stateObj.attributes.device_class;
|
||||
const domain = computeDomain(entityId);
|
||||
const entity = entities[entityId] as EntityRegistryDisplayEntry | undefined;
|
||||
const translationKey = entity?.translation_key;
|
||||
@@ -46,7 +52,13 @@ export const computeAttributeNameDisplay = (
|
||||
localize(
|
||||
`component.${entity.platform}.entity.${domain}.${translationKey}.state_attributes.${attribute}.name`
|
||||
)) ||
|
||||
localize(`component.${domain}.state_attributes._.${attribute}.name`) ||
|
||||
(deviceClass &&
|
||||
localize(
|
||||
`component.${domain}.entity_component.${deviceClass}.state_attributes.${attribute}.name`
|
||||
)) ||
|
||||
localize(
|
||||
`component.${domain}.entity_component._.state_attributes.${attribute}.name`
|
||||
) ||
|
||||
attribute
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user