From 6f01528bbd2d2835571b5fa5b59183d5550a451e Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Fri, 2 Jun 2023 02:10:27 +0200 Subject: [PATCH] Update entity component state (attributes) translations structure (#1714) --- docs/internationalization/core.md | 89 +++++++++++++++++-------------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/docs/internationalization/core.md b/docs/internationalization/core.md index 39bbc516..c31baaa9 100644 --- a/docs/internationalization/core.md +++ b/docs/internationalization/core.md @@ -205,29 +205,6 @@ To differentiate entities and their translations, provide different translation } ``` -#### State of entity components - -If your integration provides entities under its domain, you will want to translate the states. You do this by offering a `state` object, that contains translations for states with different device classes. The key `_` is used for entities without a device class. - -```json -{ - "state": { - "problem": { - "off": "OK", - "on": "Problem" - }, - "safety": { - "off": "Safe", - "on": "Unsafe" - }, - "_": { - "off": "[%key:common::state::off%]", - "on": "[%key:common::state::on%]" - } - } -} -``` - #### Entity state attributes Integrations can provide translations for its entities' state attributes under other integrations like sensor if the base entity component does not provide translations, or if the translation provided by the base entity component do not match the integration's entity. To do this, provide an `entity` object, that contains translations for entity state attributes and set the entity's `translation_key` property to a key under a domain in the `entity` object. @@ -264,6 +241,34 @@ To differentiate entities and their translations, provide different translation } } ``` +#### State of entity components + +If your integration provides entities under its domain, you will want to translate the states. You do this by offering a `states` object under the `entity_component` dictionary, that contains translations for states with different device classes. The key `_` is used for entities without a device class. + +```json +{ + "entity_component" { + "problem": { + "state": { + "off": "OK", + "on": "Problem" + } + }, + "safety": { + "state": { + "off": "Safe", + "on": "Unsafe" + } + }, + "_": { + "state": { + "off": "[%key:common::state::off%]", + "on": "[%key:common::state::on%]" + } + } + } +} +``` #### Entity attribute name and state of entity components @@ -271,28 +276,30 @@ To differentiate entities and their translations, provide different translation Translation of entity attribute names and states also requires frontend support, which is currently only available for `climate` entities. ::: -If your integration provides entities under its domain, you will want to translate the name of entity attributes and also entity state attributes. You do this by offering a `state_attributes` object, that contains translations for entity attributes with different device classes. The key `_` is used for entities without a device class. +If your integration provides entities under its domain, you will want to translate the name of entity attributes and also entity state attributes. You do this by offering a `state_attributes` object in the `entity_component` dictionary, that contains translations for entity attributes with different device classes. The key `_` is used for entities without a device class. ```json { - "state_attributes": { + "entity_component": { "_": { - "aux_heat": { "name": "Aux heat" }, - "current_humidity": { "name": "Current humidity" }, - "current_temperature": { "name": "Current temperature" }, - "fan_mode": { - "name": "Fan mode", - "state": { - "off": "[%key:common::state::off%]", - "on": "[%key:common::state::on%]", - "auto": "Auto", - "low": "Low", - "medium": "Medium", - "high": "High", - "top": "Top", - "middle": "Middle", - "focus": "Focus", - "diffuse": "Diffuse" + "state_attributes": { + "aux_heat": { "name": "Aux heat" }, + "current_humidity": { "name": "Current humidity" }, + "current_temperature": { "name": "Current temperature" }, + "fan_mode": { + "name": "Fan mode", + "state": { + "off": "[%key:common::state::off%]", + "on": "[%key:common::state::on%]", + "auto": "Auto", + "low": "Low", + "medium": "Medium", + "high": "High", + "top": "Top", + "middle": "Middle", + "focus": "Focus", + "diffuse": "Diffuse" + } } } }