Add description to service translations (#21759)

This commit is contained in:
Paul Bottein 2024-08-26 11:33:51 +02:00 committed by GitHub
parent b4dd953128
commit 3037bf494c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -497,6 +497,11 @@ export class HaServiceControl extends LitElement {
dataField.name ||
dataField.key}
>
${this._renderSectionDescription(
dataField,
domain,
serviceName
)}
${Object.entries(dataField.fields).map(([key, field]) =>
this._renderField(
{ key, ...field },
@ -517,6 +522,22 @@ export class HaServiceControl extends LitElement {
)} `;
}
private _renderSectionDescription(
dataField: ExtHassService["fields"][number],
domain: string | undefined,
serviceName: string | undefined
) {
const description = this.hass!.localize(
`component.${domain}.services.${serviceName}.sections.${dataField.key}.description`
);
if (!description) {
return nothing;
}
return html`<p>${description}</p>`;
}
private _renderField = (
dataField: ExtHassService["fields"][number],
hasOptional: boolean,