#101 pass the strings as attributes and update i18n string in template

master
Agriya Dev5 2021-05-21 11:47:17 +05:30
parent 480387e308
commit 522860ef6a
2 changed files with 7 additions and 2 deletions

View File

@ -88,6 +88,7 @@ class EditorStartup {
// canvas menu added to DOM // canvas menu added to DOM
const dialogBox = document.createElement('se-cmenu_canvas-dialog'); const dialogBox = document.createElement('se-cmenu_canvas-dialog');
dialogBox.setAttribute('id', 'se-cmenu_canvas'); dialogBox.setAttribute('id', 'se-cmenu_canvas');
dialogBox.setAttribute('i18next-tools-cut', this.i18next.t('tools.cut'));
document.body.append(dialogBox); document.body.append(dialogBox);
// alertDialog added to DOM // alertDialog added to DOM
const alertBox = document.createElement('se-alert-dialog'); const alertBox = document.createElement('se-alert-dialog');

View File

@ -68,7 +68,7 @@ template.innerHTML = `
<ul id="cmenu_canvas" class="contextMenu"> <ul id="cmenu_canvas" class="contextMenu">
<li> <li>
<a href="#cut" id="se-cut"> <a href="#cut" id="se-cut">
${svgEditor.i18next.t('tools.cut')}<span class="shortcut">META+X</span> <span class="shortcut">META+X</span>
</a> </a>
</li> </li>
<li> <li>
@ -150,7 +150,7 @@ export class SeCMenuDialog extends HTMLElement {
* @returns {any} observed * @returns {any} observed
*/ */
static get observedAttributes () { static get observedAttributes () {
return [ 'disableallmenu', 'enablemenuitems', 'disablemenuitems' ]; return [ 'disableallmenu', 'enablemenuitems', 'disablemenuitems', 'i18next-tools-cut' ];
} }
/** /**
* @function attributeChangedCallback * @function attributeChangedCallback
@ -185,6 +185,10 @@ export class SeCMenuDialog extends HTMLElement {
selEle.parentElement.classList.add('disabled'); selEle.parentElement.classList.add('disabled');
}); });
break; break;
case 'i18next-tools-cut':
var textnode = document.createTextNode(newValue);
this._shadowRoot.querySelector('#se-cut').prepend(textnode);
break;
default: default:
// super.attributeChangedCallback(name, oldValue, newValue); // super.attributeChangedCallback(name, oldValue, newValue);
break; break;