翻译 entity 的 name 和 attributes
现在可以翻译 entity 的 name,且这优于在 Python 实现中硬编码自然语言名称。此外,entity components 提供共享翻译,例如用于 binary sensor device class 的翻译,应使用这些翻译以避免重复翻译相同内容。
此外,frontend 现已完全支持翻译 entity state attributes 的 name 和值。
Warning
通过 translation_key 属性指向翻译目前仅支持具有 unique_id 的 entity。
此外,翻译 entity name 要求 has_entity_name 属性设置为 True。
翻译 entity name
以下 strings.json 示例适用于 translation_key 属性设置为 thermostat_mode 的 sensor entity:
以下 strings.json 示例适用于 translation_key 属性设置为 temperature_sensor 的 sensor entity,其中使用了 sensor 集成提供的共享翻译:
翻译 entity attributes
以下 strings.json 示例适用于 translation_key 属性设置为 ubercool 的 demo 域 climate entity,它包含自定义的 fan_mode 和 swing_mode 设置:
更多详情请参见 entity name translation、entity attribute translation 和 entity 文档。

