mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-15 21:36:31 +00:00
Document device translations (#2096)
* Document device translations * Update docs/internationalization/core.md Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update docs/internationalization/core.md * Update docs/internationalization/core.md --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
db434eb7bd
commit
cdcf0a1fe2
@ -12,6 +12,7 @@ The `strings.json` contains translations for different things that the integrati
|
||||
| ------------------- | ------------------------------------------------- |
|
||||
| `title` | Title of the integration. |
|
||||
| `config` | Translations for the config flow. |
|
||||
| `device` | Translations for devices. |
|
||||
| `device_automation` | Translations for device automations. |
|
||||
| `entity` | Translations for entities. |
|
||||
| `entity_component` | Translations for entity components. |
|
||||
@ -224,6 +225,37 @@ The translation strings for repairs issues are defined under the `issues` key. A
|
||||
}
|
||||
```
|
||||
|
||||
### Devices
|
||||
|
||||
#### Name of devices
|
||||
Integrations can provide translations for names of its devices. To do this, provide a `device` object, that contains translations of the names and set the device's `translation_key` to a key under a domain in the `device` object.
|
||||
If the device's `translation_key` is not `None`, the `name` which is either set in an entity's `device_info` property or passed to `DeviceRegistry.async_get_or_create`, will be ignored. If the `device` object does not provide a translated name for the specified `translation_key`, the `translation_key` will be used as device name.
|
||||
|
||||
It is also supported to use placeholders within the translation. If a placeholder is defined within the translation string, the device's `translation_placeholders` has to be set accordingly.
|
||||
|
||||
The following example `strings.json` is for a device with its `translation_key` set to `power_strip`:
|
||||
```json
|
||||
{
|
||||
"device": {
|
||||
"power_strip": {
|
||||
"name": "Power strip"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The following example `strings.json` is for a device with its `translation_key` property set to `n_ch_power_strip` and a placeholder `number_of_sockets`:
|
||||
|
||||
```json
|
||||
{
|
||||
"device": {
|
||||
"n_ch_power_strip": {
|
||||
"name": "Power strip with {number_of_sockets} sockets"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Entities
|
||||
|
||||
#### Name of entities
|
||||
|
Loading…
x
Reference in New Issue
Block a user