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 <marhje52@gmail.com>

* Update core.md

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Erik Montnemery 2023-03-13 14:04:08 +01:00 committed by GitHub
parent c560ad7fde
commit c71b2177b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.