Translated hui-editor and hui-root pages (#4142)

This commit is contained in:
springstan 2019-10-29 13:15:47 +01:00 committed by Bram Kragten
parent b41f4777d4
commit 6196bbdc5e
4 changed files with 54 additions and 12 deletions

View File

@ -74,7 +74,10 @@ class LovelacePanel extends LitElement {
if (state === "error") { if (state === "error") {
return html` return html`
<hass-error-screen title="Lovelace" .error="${this._errorMsg}"> <hass-error-screen
title="${this.hass!.localize("domain.lovelace")}"
.error="${this._errorMsg}"
>
<mwc-button on-click="_forceFetchConfig" <mwc-button on-click="_forceFetchConfig"
>${this.hass!.localize( >${this.hass!.localize(
"ui.panel.lovelace.reload_lovelace" "ui.panel.lovelace.reload_lovelace"

View File

@ -157,7 +157,11 @@ class LovelaceFullConfigEditor extends LitElement {
private _closeEditor() { private _closeEditor() {
if (this._changed) { if (this._changed) {
if ( if (
!confirm("You have unsaved changes, are you sure you want to exit?") !confirm(
this.hass.localize(
"ui.panel.lovelace.editor.raw_editor.confirm_unsaved_changes"
)
)
) { ) {
return; return;
} }
@ -174,7 +178,9 @@ class LovelaceFullConfigEditor extends LitElement {
if (this.yamlEditor.hasComments) { if (this.yamlEditor.hasComments) {
if ( if (
!confirm( !confirm(
"Your config contains comment(s), these will not be saved. Do you want to continue?" this.hass.localize(
"ui.panel.lovelace.editor.raw_editor.confirm_unsaved_comments"
)
) )
) { ) {
return; return;
@ -185,20 +191,38 @@ class LovelaceFullConfigEditor extends LitElement {
try { try {
value = safeLoad(this.yamlEditor.value); value = safeLoad(this.yamlEditor.value);
} catch (err) { } catch (err) {
alert(`Unable to parse YAML: ${err}`); alert(
this.hass.localize(
"ui.panel.lovelace.editor.raw_editor.error_parse_yaml",
"error",
err
)
);
this._saving = false; this._saving = false;
return; return;
} }
try { try {
value = lovelaceStruct(value); value = lovelaceStruct(value);
} catch (err) { } catch (err) {
alert(`Your config is not valid: ${err}`); alert(
this.hass.localize(
"ui.panel.lovelace.editor.raw_editor.error_invalid_config",
"error",
err
)
);
return; return;
} }
try { try {
await this.lovelace!.saveConfig(value); await this.lovelace!.saveConfig(value);
} catch (err) { } catch (err) {
alert(`Unable to save YAML: ${err}`); alert(
this.hass.localize(
"ui.panel.lovelace.editor.raw_editor.error_save_yaml",
"error",
err
)
);
} }
this._generation = this.yamlEditor this._generation = this.yamlEditor
.codemirror!.getDoc() .codemirror!.getDoc()

View File

@ -107,7 +107,9 @@ class HUIRoot extends LitElement {
</div> </div>
<paper-icon-button <paper-icon-button
icon="hass:help-circle" icon="hass:help-circle"
title="Help" title="${this.hass!.localize(
"ui.panel.lovelace.menu.help"
)}"
@click="${this._handleHelp}" @click="${this._handleHelp}"
></paper-icon-button> ></paper-icon-button>
<paper-menu-button <paper-menu-button
@ -256,7 +258,9 @@ class HUIRoot extends LitElement {
${this._editMode ${this._editMode
? html` ? html`
<ha-paper-icon-button-arrow-prev <ha-paper-icon-button-arrow-prev
title="Move view left" title="${this.hass!.localize(
"ui.panel.lovelace.editor.edit_view.move_left"
)}"
class="edit-icon view" class="edit-icon view"
@click="${this._moveViewLeft}" @click="${this._moveViewLeft}"
?disabled="${this._curView === 0}" ?disabled="${this._curView === 0}"
@ -274,13 +278,17 @@ class HUIRoot extends LitElement {
${this._editMode ${this._editMode
? html` ? html`
<ha-icon <ha-icon
title="Edit view" title="${this.hass!.localize(
"ui.panel.lovelace.editor.edit_view.edit"
)}"
class="edit-icon view" class="edit-icon view"
icon="hass:pencil" icon="hass:pencil"
@click="${this._editView}" @click="${this._editView}"
></ha-icon> ></ha-icon>
<ha-paper-icon-button-arrow-next <ha-paper-icon-button-arrow-next
title="Move view right" title="${this.hass!.localize(
"ui.panel.lovelace.editor.edit_view.move_right"
)}"
class="edit-icon view" class="edit-icon view"
@click="${this._moveViewRight}" @click="${this._moveViewRight}"
?disabled="${(this._curView! as number) + ?disabled="${(this._curView! as number) +

View File

@ -1423,7 +1423,12 @@
"header": "Edit Config", "header": "Edit Config",
"save": "Save", "save": "Save",
"unsaved_changes": "Unsaved changes", "unsaved_changes": "Unsaved changes",
"saved": "Saved" "saved": "Saved",
"confirm_unsaved_changes": "You have unsaved changes, are you sure you want to exit?",
"confirm_unsaved_comments": "Your config contains comment(s), these will not be saved. Do you want to continue?",
"error_parse_yaml": "Unable to parse YAML: {error}",
"error_invalid_config": "Your config is not valid: {error}",
"error_save_yaml": "Unable to save YAML: {error}"
}, },
"edit_lovelace": { "edit_lovelace": {
"header": "Title of your Lovelace UI", "header": "Title of your Lovelace UI",
@ -1435,7 +1440,9 @@
"header_name": "{name} View Configuration", "header_name": "{name} View Configuration",
"add": "Add view", "add": "Add view",
"edit": "Edit view", "edit": "Edit view",
"delete": "Delete view" "delete": "Delete view",
"move_left": "Move view left",
"move_right": "Move view right"
}, },
"edit_card": { "edit_card": {
"header": "Card Configuration", "header": "Card Configuration",