From 8001005a194173c46121f23a5309c03079d2663c Mon Sep 17 00:00:00 2001 From: JFH <20402845+jfhenon@users.noreply.github.com> Date: Sun, 16 May 2021 16:44:13 +0200 Subject: [PATCH] fix some translation issues --- src/editor/Editor.js | 12 +----------- src/editor/extensions/ext-imagelib/ext-imagelib.js | 6 +++--- .../ext-server_opensave/ext-server_opensave.js | 1 - src/editor/panels/LayersPanel.js | 5 ++--- src/editor/panels/TopPanel.js | 1 - 5 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/editor/Editor.js b/src/editor/Editor.js index 1ad1a808..97838825 100644 --- a/src/editor/Editor.js +++ b/src/editor/Editor.js @@ -309,7 +309,7 @@ class Editor extends EditorStartup { mod = modBits[0] + '+'; key = modBits[1]; } - keyStr += (i ? '/' : '') + mod + (this.uiStrings['key_' + key] || key); + keyStr += (i ? '/' : '') + mod + (this.i18next.t('key_' + key) || key); }); if (menu) { this.lastChild.textContent = t + ' [' + keyStr + ']'; @@ -329,15 +329,6 @@ class Editor extends EditorStartup { }); } - /** - * Expose the `uiStrings`. - * @function module:SVGthis.canvas.getUIStrings - * @returns {module:SVGthis.uiStrings} - */ - getUIStrings() { - return this.uiStrings; - } - /** * @param {boolean} editmode * @param {module:svgcanvas.SvgCanvas#event:selected} elems @@ -1054,7 +1045,6 @@ class Editor extends EditorStartup { const oldLayerName = ($id('#layerlist')) ? $id('#layerlist').querySelector('tr.layersel td.layername').textContent : ""; const renameLayer = (oldLayerName === this.i18next.t('notification.common.layer') + ' 1'); - // this.svgCanvas.setUiStrings(allStrings); this.setTitles(); if (renameLayer) { diff --git a/src/editor/extensions/ext-imagelib/ext-imagelib.js b/src/editor/extensions/ext-imagelib/ext-imagelib.js index 597c9d82..47781afa 100644 --- a/src/editor/extensions/ext-imagelib/ext-imagelib.js +++ b/src/editor/extensions/ext-imagelib/ext-imagelib.js @@ -29,7 +29,7 @@ export default { const { $id } = svgEditor.svgCanvas; const imagelibStrings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); - const { uiStrings, svgCanvas } = svgEditor; + const { svgCanvas } = svgEditor; const allowedImageLibOrigins = imagelibStrings.imgLibs.map(({ url }) => { try { @@ -184,7 +184,7 @@ export default { const name = (curMeta.name || 'file'); - const message = uiStrings.notification.retrieving.replace('%s', name); + const message = svgEditor.i18next.t('notification.retrieving').replace('%s', name); if (mode !== 'm') { await seConfirm(message); @@ -411,7 +411,7 @@ export default { const button = document.createElement('button'); // eslint-disable-next-line max-len - button.innerHTML = 'icon' + uiStrings.common.cancel; + button.innerHTML = 'icon' + svgEditor.i18next.t('common.cancel'); browser.appendChild(button); button.addEventListener('click', function () { $id("imgbrowse_holder").style.display = 'none'; diff --git a/src/editor/extensions/ext-server_opensave/ext-server_opensave.js b/src/editor/extensions/ext-server_opensave/ext-server_opensave.js index 6b2df055..45b891c6 100644 --- a/src/editor/extensions/ext-server_opensave/ext-server_opensave.js +++ b/src/editor/extensions/ext-server_opensave/ext-server_opensave.js @@ -148,7 +148,6 @@ export default { c.style.height = svgCanvas.contentH; await canvg(c, data.svg); const datauri = quality ? c.toDataURL(mimeType, quality) : c.toDataURL(mimeType); - // {uiStrings} = svgEditor; // Check if there are issues let pre, note = ''; diff --git a/src/editor/panels/LayersPanel.js b/src/editor/panels/LayersPanel.js index 22b5c02d..318100bf 100644 --- a/src/editor/panels/LayersPanel.js +++ b/src/editor/panels/LayersPanel.js @@ -14,7 +14,6 @@ class LayersPanel { * @param {PlainObject} editor */ constructor(editor) { - this.uiStrings = editor.uiStrings; this.updateContextPanel = editor.topPanel.updateContextPanel; this.sidedrag = -1; this.sidedragging = false; @@ -215,11 +214,11 @@ class LayersPanel { let uniqName; let i = this.editor.svgCanvas.getCurrentDrawing().getNumLayers(); do { - uniqName = this.uiStrings.layers.layer + " " + ++i; + uniqName = this.editor.i18next.t("layers.layer") + " " + ++i; } while (this.editor.svgCanvas.getCurrentDrawing().hasLayer(uniqName)); const newName = prompt( - this.i18next.t('notification.enterUniqueLayerName'), + this.editor.i18next.t('notification.enterUniqueLayerName'), uniqName ); if (!newName) { diff --git a/src/editor/panels/TopPanel.js b/src/editor/panels/TopPanel.js index 625c9ea3..bf93ff59 100644 --- a/src/editor/panels/TopPanel.js +++ b/src/editor/panels/TopPanel.js @@ -15,7 +15,6 @@ class TopPanel { */ constructor(editor) { this.editor = editor; - this.uiStrings = editor.uiStrings; } /** * @type {module}