computeStateDisplay does not utilize translation_key
mill1000 opened this issue · comments
The current implementation of computeStateDisplay
does not utilize an entity's translation_key which can result in unlocalized states.
e.g.
As of Core 2023.4.0, The transmission status sensor is capitalized when used in Entities, but not in multiple-entity-row
The current implementation:
lovelace-multiple-entity-row/src/lib/compute_state_display.js
Lines 106 to 114 in e2d2508
Possible correct implementation from the frontend.
return (
(entity?.translation_key &&
localize(
`component.${entity.platform}.entity.${domain}.${entity.translation_key}.state.${state}`
)) ||
// Return device class translation
(attributes.device_class &&
localize(
`component.${domain}.entity_component.${attributes.device_class}.state.${state}`
)) ||
// Return default translation
localize(`component.${domain}.entity_component._.state.${state}`) ||
// We don't know! Return the raw state.
state
);
After some tweaking replacement code indeed works. I have committed changes to my fork, but I need to find some time to check if adapted entity?.translation_key
condition is changed correctly before preparing pull request.
I made a PR as well. #293
Closed via #293