Make thingtalk dialogs translatable (#7574)

This commit is contained in:
Philip Allgaier 2020-11-05 16:15:16 +01:00 committed by GitHub
parent 028ae061da
commit 0037cd2e69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 16 deletions

View File

@ -85,13 +85,22 @@ class DialogThingtalk extends LitElement {
.opened=${this._opened}
@opened-changed=${this._openedChanged}
>
<h2>Create a new automation</h2>
<h2>
${this.hass.localize(
`ui.panel.config.automation.thingtalk.task_selection.header`
)}
</h2>
<paper-dialog-scrollable>
${this._error ? html` <div class="error">${this._error}</div> ` : ""}
Type below what this automation should do, and we will try to convert
it into a Home Assistant automation. (only English is supported for
now)<br /><br />
For example:
${this.hass.localize(
`ui.panel.config.automation.thingtalk.task_selection.introduction`
)}<br /><br />
${this.hass.localize(
`ui.panel.config.automation.thingtalk.task_selection.language_note`
)}<br /><br />
${this.hass.localize(
`ui.panel.config.automation.thingtalk.task_selection.for_example`
)}
<ul @click=${this._handleExampleClick}>
<li>
<button class="link">
@ -130,7 +139,7 @@ class DialogThingtalk extends LitElement {
</paper-dialog-scrollable>
<div class="paper-dialog-buttons">
<mwc-button class="left" @click="${this._skip}">
Skip
${this.hass.localize(`ui.common.skip`)}
</mwc-button>
<mwc-button @click="${this._generate}" .disabled=${this._submitting}>
${this._submitting
@ -140,7 +149,7 @@ class DialogThingtalk extends LitElement {
title="Creating your automation..."
></ha-circular-progress>`
: ""}
Create automation
${this.hass.localize(`ui.panel.config.automation.thingtalk.create`)}
</mwc-button>
</div>
</ha-paper-dialog>
@ -150,7 +159,9 @@ class DialogThingtalk extends LitElement {
private async _generate() {
this._value = this._input!.value as string;
if (!this._value) {
this._error = "Enter a command or tap skip.";
this._error = this.hass.localize(
`ui.panel.config.automation.thingtalk.task_selection.error_empty`
);
return;
}
this._submitting = true;
@ -169,7 +180,9 @@ class DialogThingtalk extends LitElement {
this._submitting = false;
if (!Object.keys(config).length) {
this._error = "We couldn't create an automation for that (yet?).";
this._error = this.hass.localize(
`ui.panel.config.automation.thingtalk.task_selection.error_unsupported`
);
} else if (Object.keys(placeholders).length) {
this._config = config;
this._placeholders = placeholders;

View File

@ -131,7 +131,11 @@ export class ThingTalkPlaceholders extends SubscribeMixin(LitElement) {
.opened=${this.opened}
@opened-changed="${this._openedChanged}"
>
<h2>Great! Now we need to link some devices.</h2>
<h2>
${this.hass.localize(
`ui.panel.config.automation.thingtalk.link_devices.header`
)}
</h2>
<paper-dialog-scrollable>
${this._error ? html` <div class="error">${this._error}</div> ` : ""}
${Object.entries(this.placeholders).map(
@ -168,8 +172,9 @@ export class ThingTalkPlaceholders extends SubscribeMixin(LitElement) {
${extraInfo && extraInfo.manualEntity
? html`
<h3>
One or more devices have more than one matching
entity, please pick the one you want to use.
${this.hass.localize(
`ui.panel.config.automation.thingtalk.link_devices.ambiguous_entities`
)}
</h3>
${Object.keys(extraInfo.manualEntity).map(
(idx) => html`
@ -226,7 +231,9 @@ export class ThingTalkPlaceholders extends SubscribeMixin(LitElement) {
}
return html`
<div class="error">
Unknown placeholder<br />
${this.hass.localize(
`ui.panel.config.automation.thingtalk.link_devices.unknown_placeholder`
)}<br />
${placeholder.domains}<br />
${placeholder.fields.map(
(field) => html` ${field}<br /> `
@ -239,10 +246,10 @@ export class ThingTalkPlaceholders extends SubscribeMixin(LitElement) {
</paper-dialog-scrollable>
<div class="paper-dialog-buttons">
<mwc-button class="left" @click="${this.skip}">
Skip
${this.hass.localize(`ui.common.skip`)}
</mwc-button>
<mwc-button @click="${this._done}" .disabled=${!this._isDone}>
Create automation
${this.hass.localize(`ui.panel.config.automation.thingtalk.create`)}
</mwc-button>
</div>
</ha-paper-dialog>

View File

@ -275,6 +275,7 @@
"save": "Save",
"yes": "Yes",
"no": "No",
"skip": "Skip",
"menu": "Menu",
"overflow_menu": "Overflow menu",
"successfully_saved": "Successfully saved",
@ -1119,7 +1120,7 @@
"event_data": "Event data",
"context_users": "Limit to events triggered by",
"context_user_picked": "User firing event",
"context_user_pick": "Add user"
"context_user_pick": "Select user"
},
"geo_location": {
"label": "Geolocation",
@ -1347,6 +1348,22 @@
}
}
}
},
"thingtalk": {
"create": "Create automation",
"task_selection": {
"header": "Create a new automation",
"introduction": "Type below what this automation should do, and we will try to convert it into a Home Assistant automation.",
"language_note": "Note: Only English is supported for now.",
"for_example": "For example:",
"error_empty": "Enter a command or tap skip.",
"error_unsupported": "We couldn't create an automation for that (yet?)."
},
"link_devices": {
"header": "Great! Now we need to link some devices",
"ambiguous_entities": "One or more devices have more than one matching entity, please pick the one you want to use.",
"unknown_placeholder": "Unknown placeholder"
}
}
},
"script": {