mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Complete service translation support in service dev tools (#17399)
This commit is contained in:
parent
17c9e91092
commit
5ed767804c
@ -58,6 +58,9 @@ class HaPanelDevService extends LitElement {
|
|||||||
|
|
||||||
protected firstUpdated(params) {
|
protected firstUpdated(params) {
|
||||||
super.firstUpdated(params);
|
super.firstUpdated(params);
|
||||||
|
this.hass.loadBackendTranslation("services");
|
||||||
|
this.hass.loadBackendTranslation("selector");
|
||||||
|
|
||||||
const serviceParam = extractSearchParam("service");
|
const serviceParam = extractSearchParam("service");
|
||||||
if (serviceParam) {
|
if (serviceParam) {
|
||||||
this._serviceData = {
|
this._serviceData = {
|
||||||
@ -95,6 +98,14 @@ class HaPanelDevService extends LitElement {
|
|||||||
|
|
||||||
const isValid = this._isValid(this._serviceData, fields, target);
|
const isValid = this._isValid(this._serviceData, fields, target);
|
||||||
|
|
||||||
|
const domain = this._serviceData?.service
|
||||||
|
? computeDomain(this._serviceData?.service)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const serviceName = this._serviceData?.service
|
||||||
|
? computeObjectId(this._serviceData?.service)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<p>
|
<p>
|
||||||
@ -251,8 +262,16 @@ class HaPanelDevService extends LitElement {
|
|||||||
(field) =>
|
(field) =>
|
||||||
html` <tr>
|
html` <tr>
|
||||||
<td><pre>${field.key}</pre></td>
|
<td><pre>${field.key}</pre></td>
|
||||||
<td>${field.description}</td>
|
<td>
|
||||||
<td>${field.example}</td>
|
${this.hass.localize(
|
||||||
|
`component.${domain}.services.${serviceName}.fields.${field.key}.description`
|
||||||
|
) || field.description}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
${this.hass.localize(
|
||||||
|
`component.${domain}.services.${serviceName}.fields.${field.key}.example`
|
||||||
|
) || field.example}
|
||||||
|
</td>
|
||||||
</tr>`
|
</tr>`
|
||||||
)}
|
)}
|
||||||
</table>
|
</table>
|
||||||
@ -430,6 +449,14 @@ class HaPanelDevService extends LitElement {
|
|||||||
this.hass.services,
|
this.hass.services,
|
||||||
this._serviceData?.service
|
this._serviceData?.service
|
||||||
);
|
);
|
||||||
|
const domain = this._serviceData?.service
|
||||||
|
? computeDomain(this._serviceData?.service)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const serviceName = this._serviceData?.service
|
||||||
|
? computeObjectId(this._serviceData?.service)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const example = {};
|
const example = {};
|
||||||
fields.forEach((field) => {
|
fields.forEach((field) => {
|
||||||
if (field.example) {
|
if (field.example) {
|
||||||
@ -437,7 +464,10 @@ class HaPanelDevService extends LitElement {
|
|||||||
try {
|
try {
|
||||||
value = load(field.example);
|
value = load(field.example);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
value = field.example;
|
value =
|
||||||
|
this.hass.localize(
|
||||||
|
`component.${domain}.services.${serviceName}.fields.${field.key}.example`
|
||||||
|
) || field.example;
|
||||||
}
|
}
|
||||||
example[field.key] = value;
|
example[field.key] = value;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user