Skip to content

Commit a0c58d3

Browse files
authored
Add translation information for triggers and conditions (#3219)
1 parent 2ddea9e commit a0c58d3

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

docs/internationalization/core.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The `strings.json` contains translations for different things that the integrati
1212
| ------------------- | ------------------------------------------------- |
1313
| `title` | Title of the integration. |
1414
| `common` | Shared strings. |
15+
| `conditions` | Conditions of the integration. |
1516
| `config` | Translations for the config flow. |
1617
| `device` | Translations for devices. |
1718
| `device_automation` | Translations for device automations. |
@@ -22,6 +23,7 @@ The `strings.json` contains translations for different things that the integrati
2223
| `options` | Translations for the options flow. |
2324
| `selectors` | Selectors of the integration. |
2425
| `services` | Service actions of the integration. |
26+
| `triggers` | Triggers of the integration. |
2527

2628
### Title
2729

@@ -250,6 +252,60 @@ The translation strings for device automations are defined under the `device_aut
250252

251253
```
252254

255+
### Triggers
256+
257+
The translations of trigger strings are defined under the `triggers` key. The structure follows the same format as [service actions](#service-actions): each trigger is keyed by its trigger key (the key returned by `async_get_triggers`) and supports translating the `name` and `description` of the trigger, the `name` and `description` of each of the trigger's `fields`, and the `name` and `description` of each collapsible `section` of fields.
258+
259+
The structure of a trigger (its fields, sections and selectors) is defined in the `triggers.yaml` file. See the [Automations](/docs/automations) documentation for more information.
260+
261+
```json
262+
{
263+
"triggers": {
264+
"occupancy_cleared": {
265+
"name": "Occupancy cleared",
266+
"description": "Triggers when occupancy is cleared.",
267+
"fields": {
268+
"for": {
269+
"name": "For",
270+
"description": "The duration the occupancy must be cleared before triggering."
271+
}
272+
}
273+
}
274+
}
275+
}
276+
```
277+
278+
:::note
279+
Triggers may use selectors in their `fields`. The translation of those selectors can be provided using the `translation_key` property on the selector definition in the `triggers.yaml` file. See the [Selectors](#selectors) section for more information.
280+
:::
281+
282+
### Conditions
283+
284+
The translations of condition strings are defined under the `conditions` key. Just like [triggers](#triggers), the structure follows the same format as [service actions](#service-actions): each condition is keyed by its condition key (the key returned by `async_get_conditions`) and supports translating the `name` and `description` of the condition, the `name` and `description` of each of the condition's `fields`, and the `name` and `description` of each collapsible `section` of fields.
285+
286+
The structure of a condition (its fields, sections and selectors) is defined in the `conditions.yaml` file. See the [Automations](/docs/automations) documentation for more information.
287+
288+
```json
289+
{
290+
"conditions": {
291+
"door_state": {
292+
"name": "Door state",
293+
"description": "Tests if the door has a specific state.",
294+
"fields": {
295+
"state": {
296+
"name": "State",
297+
"description": "The state the door must have for the condition to pass."
298+
}
299+
}
300+
}
301+
}
302+
}
303+
```
304+
305+
:::note
306+
Conditions may use selectors in their `fields`. The translation of those selectors can be provided using the `translation_key` property on the selector definition in the `conditions.yaml` file. See the [Selectors](#selectors) section for more information.
307+
:::
308+
253309
### Exceptions
254310

255311
Localization is supported for `HomeAssistantError` and its subclasses.

0 commit comments

Comments
 (0)