From c71b2177b9e5f7d162221972690d9388e20cbc48 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 13 Mar 2023 14:04:08 +0100 Subject: [PATCH] Document translation of entity names (#1707) * Document translation of entity names * Adjust according to changes in the implementation * Update docs/internationalization/core.md Co-authored-by: Martin Hjelmare * Update core.md --------- Co-authored-by: Martin Hjelmare --- docs/internationalization/core.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/internationalization/core.md b/docs/internationalization/core.md index 98c81d40..5dab55f5 100644 --- a/docs/internationalization/core.md +++ b/docs/internationalization/core.md @@ -149,6 +149,23 @@ The translation strings for repairs issues are defined under the `issues` key. A ### Entities +#### Name of entities +Integrations can provide translations for names of its entities. To do this, provide an `entity` object, that contains translations of the names and set the entity's `translation_key` property to a key under a domain in the `entity` object. +If the entity's `translation_key` property is not `None` and the `entity` object provides a translated name, `EntityDescription.name` will be ignored. + +The following example `strings.json` is for a `sensor` entity with its `translation_key` property set to `thermostat_mode`: +```json +{ + "entity": { + "sensor": { + "thermostat_mode": { + "name": "Thermostat mode" + } + } + } +} +``` + #### State of entities Integrations can provide translations for states of its entities 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 states and set the entity's `translation_key` property to a key under a domain in the `entity` object.