From 88512f208819238967eb7a0e67306c560f07eae0 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Fri, 21 May 2021 18:15:09 +0530 Subject: [PATCH] #101 dialog i18n are change to new approach --- src/editor/dialogs/cmenuLayersDialog.js | 25 ++++++++++++++++++++++++- src/editor/panels/LayersPanel.js | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/editor/dialogs/cmenuLayersDialog.js b/src/editor/dialogs/cmenuLayersDialog.js index 7c6e3096..93e91da8 100644 --- a/src/editor/dialogs/cmenuLayersDialog.js +++ b/src/editor/dialogs/cmenuLayersDialog.js @@ -93,12 +93,23 @@ export class SeCMenuLayerDialog extends HTMLElement { this.$mergeDownLink = this._shadowRoot.querySelector('#se-merge-down'); this.$mergeAllLink = this._shadowRoot.querySelector('#se-merge-all'); } + /** + * @function init + * @param {any} name + * @returns {void} + */ + init (i18next) { + this.setAttribute('layers-dupe', i18next.t('layers.dupe')); + this.setAttribute('layers-del', i18next.t('layers.del')); + this.setAttribute('layers-merge_down', i18next.t('layers.merge_down')); + this.setAttribute('layers-merge_all', i18next.t('layers.merge_all')); + } /** * @function observedAttributes * @returns {any} observed */ static get observedAttributes () { - return [ 'value', 'leftclick' ]; + return [ 'value', 'leftclick', 'layers-dupe', 'layers-del', 'layers-merge_down', 'layers-merge_all' ]; } /** * @function attributeChangedCallback @@ -117,6 +128,18 @@ export class SeCMenuLayerDialog extends HTMLElement { this._workarea = document.getElementById(this.source); } break; + case 'layers-dupe': + this.$duplicateLink.textContent = newValue; + break; + case 'layers-del': + this.$deleteLink.textContent = newValue; + break; + case 'layers-merge_down': + this.$mergeDownLink.textContent = newValue; + break; + case 'layers-merge_all': + this.$mergeAllLink.textContent = newValue; + break; default: // super.attributeChangedCallback(name, oldValue, newValue); break; diff --git a/src/editor/panels/LayersPanel.js b/src/editor/panels/LayersPanel.js index b374ea9a..34eac5be 100644 --- a/src/editor/panels/LayersPanel.js +++ b/src/editor/panels/LayersPanel.js @@ -150,11 +150,13 @@ class LayersPanel { menuMore.value = "layer_moreopts"; menuMore.setAttribute("leftclick", true); document.body.append(menuMore); + menuMore.init(i18next); const menuLayerBox = document.createElement("se-cmenu-layers"); menuLayerBox.setAttribute("id", "se-cmenu-layers-list"); menuLayerBox.value = "layerlist"; menuLayerBox.setAttribute("leftclick", false); document.body.append(menuLayerBox); + menuLayerBox.init(i18next); document .getElementById("layer_new") .addEventListener("click", this.newLayer.bind(this));