From 5264545bb9639d5c331e2af2aec24c511462e4a0 Mon Sep 17 00:00:00 2001 From: springstan Date: Sat, 26 Oct 2019 18:58:08 +0200 Subject: [PATCH 1/3] Translated config flow form and steps --- .../config-flow/show-dialog-config-flow.ts | 8 ++++- src/dialogs/config-flow/step-flow-abort.ts | 12 +++++-- .../config-flow/step-flow-create-entry.ts | 36 +++++++++++++++---- src/dialogs/config-flow/step-flow-form.ts | 11 +++--- src/translations/en.json | 15 ++++++-- 5 files changed, 67 insertions(+), 15 deletions(-) diff --git a/src/dialogs/config-flow/show-dialog-config-flow.ts b/src/dialogs/config-flow/show-dialog-config-flow.ts index c91723b9c27e..a3872ccc006b 100644 --- a/src/dialogs/config-flow/show-dialog-config-flow.ts +++ b/src/dialogs/config-flow/show-dialog-config-flow.ts @@ -122,7 +122,13 @@ export const showConfigFlowDialog = ( ` : ""} -

Created config for ${step.title}.

+

+ ${hass.localize( + "ui.panel.config.integrations.config_flow.external_step.created_config", + "name", + step.title + )} +

`; }, }); diff --git a/src/dialogs/config-flow/step-flow-abort.ts b/src/dialogs/config-flow/step-flow-abort.ts index 3af1b63d9200..f47039f8d0e1 100644 --- a/src/dialogs/config-flow/step-flow-abort.ts +++ b/src/dialogs/config-flow/step-flow-abort.ts @@ -26,12 +26,20 @@ class StepFlowAbort extends LitElement { protected render(): TemplateResult | void { return html` -

Aborted

+

+ ${this.hass.localize( + "ui.panel.config.integrations.config_entry.aborted" + )} +

${this.flowConfig.renderAbortDescription(this.hass, this.step)}
- Close + ${this.hass.localize( + "ui.panel.config.integrations.config_entry.close" + )}
`; } diff --git a/src/dialogs/config-flow/step-flow-create-entry.ts b/src/dialogs/config-flow/step-flow-create-entry.ts index cd1183ec16ad..3deaaac4c0d4 100644 --- a/src/dialogs/config-flow/step-flow-create-entry.ts +++ b/src/dialogs/config-flow/step-flow-create-entry.ts @@ -63,7 +63,9 @@ class StepFlowCreateEntry extends LitElement { ${device.model} (${device.manufacturer}) @@ -91,11 +93,19 @@ class StepFlowCreateEntry extends LitElement {
${this.devices.length > 0 ? html` - Add Area + ${localize( + "ui.panel.config.integrations.config_entry.add_area" + )} ` : ""} - Finish + ${localize( + "ui.panel.config.integrations.config_entry.finish" + )}
`; } @@ -105,7 +115,11 @@ class StepFlowCreateEntry extends LitElement { } private async _addArea() { - const name = prompt("Name of the new area?"); + const name = prompt( + this.hass.localize( + "ui.panel.config.integrations.config_entry.name_new_area" + ) + ); if (!name) { return; } @@ -115,7 +129,11 @@ class StepFlowCreateEntry extends LitElement { }); this.areas = [...this.areas, area]; } catch (err) { - alert("Failed to create area."); + alert( + this.hass.localize( + "ui.panel.config.integrations.config_entry.failed_create_area" + ) + ); } } @@ -134,7 +152,13 @@ class StepFlowCreateEntry extends LitElement { area_id: area, }); } catch (err) { - alert(`Error saving area: ${err.message}`); + alert( + this.hass.localize( + "ui.panel.config.integrations.config_entry.error_saving_area", + "name", + "err.message" + ) + ); dropdown.value = null; } } diff --git a/src/dialogs/config-flow/step-flow-form.ts b/src/dialogs/config-flow/step-flow-form.ts index 3b3d2fbad34b..9aa04719bc5a 100644 --- a/src/dialogs/config-flow/step-flow-form.ts +++ b/src/dialogs/config-flow/step-flow-form.ts @@ -87,14 +87,17 @@ class StepFlowForm extends LitElement { - Submit + >${this.hass.localize( + "ui.panel.config.integrations.config_entry.submit" + )} ${!allRequiredInfoFilledIn ? html` - - Not all required fields are filled in. + ${this.hass.localize( + "ui.panel.config.integrations.config_entry.not_all_fields_required" + )} ` : html``} diff --git a/src/translations/en.json b/src/translations/en.json index 4c0b4be9e280..1a3e8b72f084 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1212,12 +1212,23 @@ "device_unavailable": "device unavailable", "entity_unavailable": "entity unavailable", "area": "In {area}", - "no_area": "No Area" + "no_area": "No Area", + "area_picker_label": "Area", + "add_area": "Add Area", + "finish": "Finish", + "name_new_area": "Name of the new area?", + "failed_create_area": "Failed to create area.", + "error_saving_area": "Error saving area: {name}", + "aborted": "Aborted", + "close": "Close", + "submit": "Submit", + "not_all_fields_required": "Not all required fields are filled in." }, "config_flow": { "external_step": { "description": "This step requires you to visit an external website to be completed.", - "open_site": "Open website" + "open_site": "Open website", + "created_config": "Created config for {name}." } } }, From 3cd31a26a03952acb61c9c8b02548fb0d3fda182 Mon Sep 17 00:00:00 2001 From: springstan Date: Tue, 29 Oct 2019 18:07:48 +0100 Subject: [PATCH 2/3] Moved translation from config_entry to config_flow --- .../config-flow/show-dialog-config-flow.ts | 2 +- src/dialogs/config-flow/step-flow-abort.ts | 4 ++-- .../config-flow/step-flow-create-entry.ts | 14 +++++------ src/dialogs/config-flow/step-flow-form.ts | 4 ++-- src/translations/en.json | 24 +++++++++---------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/dialogs/config-flow/show-dialog-config-flow.ts b/src/dialogs/config-flow/show-dialog-config-flow.ts index a3872ccc006b..6f54f010ac54 100644 --- a/src/dialogs/config-flow/show-dialog-config-flow.ts +++ b/src/dialogs/config-flow/show-dialog-config-flow.ts @@ -124,7 +124,7 @@ export const showConfigFlowDialog = ( : ""}

${hass.localize( - "ui.panel.config.integrations.config_flow.external_step.created_config", + "ui.panel.config.integrations.config_flow.created_config", "name", step.title )} diff --git a/src/dialogs/config-flow/step-flow-abort.ts b/src/dialogs/config-flow/step-flow-abort.ts index f47039f8d0e1..bbb337876441 100644 --- a/src/dialogs/config-flow/step-flow-abort.ts +++ b/src/dialogs/config-flow/step-flow-abort.ts @@ -28,7 +28,7 @@ class StepFlowAbort extends LitElement { return html`

${this.hass.localize( - "ui.panel.config.integrations.config_entry.aborted" + "ui.panel.config.integrations.config_flow.aborted" )}

@@ -37,7 +37,7 @@ class StepFlowAbort extends LitElement {
${this.hass.localize( - "ui.panel.config.integrations.config_entry.close" + "ui.panel.config.integrations.config_flow.close" )}
diff --git a/src/dialogs/config-flow/step-flow-create-entry.ts b/src/dialogs/config-flow/step-flow-create-entry.ts index 3deaaac4c0d4..9fe62ffd2be5 100644 --- a/src/dialogs/config-flow/step-flow-create-entry.ts +++ b/src/dialogs/config-flow/step-flow-create-entry.ts @@ -64,7 +64,7 @@ class StepFlowCreateEntry extends LitElement {
${localize( - "ui.panel.config.integrations.config_entry.add_area" + "ui.panel.config.integrations.config_flow.add_area" )} ` @@ -103,7 +103,7 @@ class StepFlowCreateEntry extends LitElement { ${localize( - "ui.panel.config.integrations.config_entry.finish" + "ui.panel.config.integrations.config_flow.finish" )} @@ -117,7 +117,7 @@ class StepFlowCreateEntry extends LitElement { private async _addArea() { const name = prompt( this.hass.localize( - "ui.panel.config.integrations.config_entry.name_new_area" + "ui.panel.config.integrations.config_flow.name_new_area" ) ); if (!name) { @@ -131,7 +131,7 @@ class StepFlowCreateEntry extends LitElement { } catch (err) { alert( this.hass.localize( - "ui.panel.config.integrations.config_entry.failed_create_area" + "ui.panel.config.integrations.config_flow.failed_create_area" ) ); } @@ -154,8 +154,8 @@ class StepFlowCreateEntry extends LitElement { } catch (err) { alert( this.hass.localize( - "ui.panel.config.integrations.config_entry.error_saving_area", - "name", + "ui.panel.config.integrations.config_flow.error_saving_area", + "error", "err.message" ) ); diff --git a/src/dialogs/config-flow/step-flow-form.ts b/src/dialogs/config-flow/step-flow-form.ts index 9aa04719bc5a..8aab2f8b563d 100644 --- a/src/dialogs/config-flow/step-flow-form.ts +++ b/src/dialogs/config-flow/step-flow-form.ts @@ -88,7 +88,7 @@ class StepFlowForm extends LitElement { @click=${this._submitStep} .disabled=${!allRequiredInfoFilledIn} >${this.hass.localize( - "ui.panel.config.integrations.config_entry.submit" + "ui.panel.config.integrations.config_flow.submit" )} @@ -96,7 +96,7 @@ class StepFlowForm extends LitElement { ? html` ${this.hass.localize( - "ui.panel.config.integrations.config_entry.not_all_fields_required" + "ui.panel.config.integrations.config_flow.not_all_fields_required" )} ` diff --git a/src/translations/en.json b/src/translations/en.json index 1a3e8b72f084..bf3f04531da9 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1212,23 +1212,23 @@ "device_unavailable": "device unavailable", "entity_unavailable": "entity unavailable", "area": "In {area}", - "no_area": "No Area", - "area_picker_label": "Area", - "add_area": "Add Area", - "finish": "Finish", - "name_new_area": "Name of the new area?", - "failed_create_area": "Failed to create area.", - "error_saving_area": "Error saving area: {name}", + "no_area": "No Area" + }, + "config_flow": { "aborted": "Aborted", "close": "Close", + "finish": "Finish", "submit": "Submit", - "not_all_fields_required": "Not all required fields are filled in." - }, - "config_flow": { + "not_all_fields_required": "Not all required fields are filled in.", + "add_area": "Add Area", + "area_picker_label": "Area", + "failed_create_area": "Failed to create area.", + "error_saving_area": "Error saving area: {error}", + "name_new_area": "Name of the new area?", + "created_config": "Created config for {name}.", "external_step": { "description": "This step requires you to visit an external website to be completed.", - "open_site": "Open website", - "created_config": "Created config for {name}." + "open_site": "Open website" } } }, From c36e0926be88594547fccc2ea4d05e796cb91681 Mon Sep 17 00:00:00 2001 From: springstan Date: Fri, 1 Nov 2019 19:55:34 +0100 Subject: [PATCH 3/3] Renamed translation key from not_all_fields_required to not_all_required_fields --- src/dialogs/config-flow/step-flow-form.ts | 2 +- src/translations/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dialogs/config-flow/step-flow-form.ts b/src/dialogs/config-flow/step-flow-form.ts index 8aab2f8b563d..98d5ff33b75e 100644 --- a/src/dialogs/config-flow/step-flow-form.ts +++ b/src/dialogs/config-flow/step-flow-form.ts @@ -96,7 +96,7 @@ class StepFlowForm extends LitElement { ? html` ${this.hass.localize( - "ui.panel.config.integrations.config_flow.not_all_fields_required" + "ui.panel.config.integrations.config_flow.not_all_required_fields" )} ` diff --git a/src/translations/en.json b/src/translations/en.json index bf3f04531da9..4760ee8e8aca 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1219,7 +1219,7 @@ "close": "Close", "finish": "Finish", "submit": "Submit", - "not_all_fields_required": "Not all required fields are filled in.", + "not_all_required_fields": "Not all required fields are filled in.", "add_area": "Add Area", "area_picker_label": "Area", "failed_create_area": "Failed to create area.",