From c730aab28f2a6af4588379b539a097445fa5add7 Mon Sep 17 00:00:00 2001
From: springstan <46536646+springstan@users.noreply.github.com>
Date: Fri, 1 Nov 2019 20:34:10 +0100
Subject: [PATCH] Translated config flow form and steps (#4140)
* Translated config flow form and steps
* Moved translation from config_entry to config_flow
* Renamed translation key from not_all_fields_required to not_all_required_fields
---
.../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 | 11 ++++++
5 files changed, 65 insertions(+), 13 deletions(-)
diff --git a/src/dialogs/config-flow/show-dialog-config-flow.ts b/src/dialogs/config-flow/show-dialog-config-flow.ts
index c91723b9c2..6f54f010ac 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.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 3af1b63d92..bbb3378764 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_flow.aborted"
+ )}
+
${this.flowConfig.renderAbortDescription(this.hass, this.step)}
- Close
+ ${this.hass.localize(
+ "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 cd1183ec16..9fe62ffd2b 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_flow.add_area"
+ )}
`
: ""}
- Finish
+ ${localize(
+ "ui.panel.config.integrations.config_flow.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_flow.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_flow.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_flow.error_saving_area",
+ "error",
+ "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 3b3d2fbad3..98d5ff33b7 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_flow.submit"
+ )}
${!allRequiredInfoFilledIn
? html`
-
- Not all required fields are filled in.
+ ${this.hass.localize(
+ "ui.panel.config.integrations.config_flow.not_all_required_fields"
+ )}
`
: html``}
diff --git a/src/translations/en.json b/src/translations/en.json
index e90789c50f..9975900315 100755
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -1269,6 +1269,17 @@
"no_area": "No Area"
},
"config_flow": {
+ "aborted": "Aborted",
+ "close": "Close",
+ "finish": "Finish",
+ "submit": "Submit",
+ "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.",
+ "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"