New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translation support for device automation extra fields #20567
base: dev
Are you sure you want to change the base?
Translation support for device automation extra fields #20567
Conversation
) || schema.name; | ||
) || | ||
localize( | ||
`component.${trigger.domain}.device_automation.extra_fields.${schema.name}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will have to load these translations somewhere, or do the device automation controls already load them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is already loaded since the backends strings.json
s
{
"device_automation": {
"condition_type": {...}
"trigger_type": {...}
}
}
keys are already loaded too. I'm not sure where this happens though 😬.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The automation editor loads them:
this.hass.loadBackendTranslation("device_automation"); |
// Returns a callback for ha-form to calculate labels per schema object | ||
return (schema) => | ||
return (schema): string => | ||
localize( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt the order be reversed? The component should be able to override the default translations I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense. Do you know where these default translations are used?
"extra_fields": {
"above": "Above",
"below": "Below",
"for": "Duration (optional)",
"zone": "[%key:ui::panel::config::automation::editor::triggers::type::zone::label%]"
},
I would think of sensor
domain, but for the "zone" key I'm not sure. Should it maybe be moved to backend (like components/sensor/strings.json
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be moved to the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved all of this to the backend and removed the translations from the frontend. home-assistant/core@c20bd32
Also moved the ComputeLabelCallback
functions to a common module so it can be used by conditions and actions too.
Proposed change
Add translation support for integration specific device trigger extra fields.
Core PR to allow new keys in
strings.json
: home-assistant/core#115892This can be tested with a core-branch adding a new device trigger for "Sun" with some dummy extra_fields
home-assistant/core#115846
Given an integrations
strings.json
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: