mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-14 04:46:29 +00:00
Add section for unit of measurement translations (#2451)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
parent
cf52c30bc0
commit
4f545c0a81
@ -467,6 +467,24 @@ If your integration provides entities under its domain, you will want to transla
|
||||
}
|
||||
```
|
||||
|
||||
#### Unit of measurement of entities
|
||||
|
||||
Integrations can provide translations for units of measurement of its entities. To do this, provide an `entity` object, that contains translations for the units 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 unit, `SensorEntityDescription.native_unit_of_measurement` and `NumberEntityDescription.native_unit_of_measurement` will be ignored.
|
||||
|
||||
The following example `strings.json` is for a `sensor` entity with its `translation_key` property set to `goal`:
|
||||
```json
|
||||
{
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"goal": {
|
||||
"unit_of_measurement": "steps"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Test translations
|
||||
|
||||
In order to test changes to translation files, the translation strings must be compiled into Home Assistant’s translation directories by running the following script:
|
||||
|
Loading…
x
Reference in New Issue
Block a user