From 45eb039eb3acd350a4933feb9b4b43b94c5cdcdc Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Fri, 21 May 2021 18:52:56 +0530 Subject: [PATCH] #101 dialogs i18n new approach changes --- src/editor/dialogs/svgSourceDialog.js | 40 +++++++++++++++++++-------- src/editor/panels/TopPanel.js | 1 + 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/editor/dialogs/svgSourceDialog.js b/src/editor/dialogs/svgSourceDialog.js index 3e8c4bb5..fa5aa22f 100644 --- a/src/editor/dialogs/svgSourceDialog.js +++ b/src/editor/dialogs/svgSourceDialog.js @@ -62,18 +62,12 @@ template.innerHTML = `
- - + +
-

- #{svgEditor.i18next.t('notification.source_dialog_note')} -

- +

+
@@ -101,12 +95,23 @@ export class SeSvgSourceEditorDialog extends HTMLElement { this.$copySec = this._shadowRoot.querySelector('#save_output_btns'); this.$applySec = this._shadowRoot.querySelector('#tool_source_back'); } + /** + * @function init + * @param {any} name + * @returns {void} + */ + init (i18next) { + this.setAttribute('tools-source_save', i18next.t('tools.source_save')); + this.setAttribute('common-cancel', i18next.t('common.cancel')); + this.setAttribute('notification-source_dialog_note', i18next.t('notification.source_dialog_note')); + this.setAttribute('config-done', i18next.t('config.done')); + } /** * @function observedAttributes * @returns {any} observed */ static get observedAttributes () { - return [ 'dialog', 'value', 'applysec', 'copysec' ]; + return [ 'dialog', 'value', 'applysec', 'copysec', 'tools-source_save', 'common-cancel', 'notification-source_dialog_note', 'config-done' ]; } /** * @function attributeChangedCallback @@ -144,6 +149,19 @@ export class SeSvgSourceEditorDialog extends HTMLElement { case 'value': this.$sourceTxt.value = newValue; break; + case 'tools-source_save': + this.$saveBtn.textContent = newValue; + break; + case 'common-cancel': + this.$cancelBtn.textContent = newValue; + break; + case 'notification-source_dialog_note': + const node = this._shadowRoot.querySelector('#copy_save_note'); + node.textContent = newValue; + break; + case 'config-done': + this.$copyBtn.textContent = newValue; + break; default: super.attributeChangedCallback(name, oldValue, newValue); break; diff --git a/src/editor/panels/TopPanel.js b/src/editor/panels/TopPanel.js index 09edeb7d..0de43c49 100644 --- a/src/editor/panels/TopPanel.js +++ b/src/editor/panels/TopPanel.js @@ -990,6 +990,7 @@ class TopPanel { ); newSeEditorDialog.setAttribute("id", "se-svg-editor-dialog"); document.body.append(newSeEditorDialog); + newSeEditorDialog.init(i18next); // register action to top panel buttons $id("tool_source").addEventListener( "click",