need loadTranslation to be repeated as dynamic import behaves differently in build mode (vs src mode)
parent
aa50c30610
commit
81a31c3dad
|
@ -8,15 +8,28 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { loadExtensionTranslation } from '../../locale.js';
|
|
||||||
|
|
||||||
const name = "eyedropper";
|
const name = "eyedropper";
|
||||||
|
|
||||||
|
const loadExtensionTranslation = async function (svgEditor) {
|
||||||
|
let translationModule;
|
||||||
|
const lang = svgEditor.configObj.pref('lang');
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line no-unsanitized/method
|
||||||
|
translationModule = await import(`./locale/${lang}.js`);
|
||||||
|
} catch (_error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.warn(`Missing translation (${lang}) for ${name} - using 'en'`);
|
||||||
|
// eslint-disable-next-line no-unsanitized/method
|
||||||
|
translationModule = await import(`./locale/en.js`);
|
||||||
|
}
|
||||||
|
svgEditor.i18next.addResourceBundle(lang, name, translationModule.default);
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name,
|
name,
|
||||||
async init(S) {
|
async init(S) {
|
||||||
const svgEditor = this;
|
const svgEditor = this;
|
||||||
await loadExtensionTranslation(svgEditor, name);
|
await loadExtensionTranslation(svgEditor);
|
||||||
const { ChangeElementCommand } = S, // , svgcontent,
|
const { ChangeElementCommand } = S, // , svgcontent,
|
||||||
// svgdoc = S.svgroot.parentNode.ownerDocument,
|
// svgdoc = S.svgroot.parentNode.ownerDocument,
|
||||||
{ svgCanvas } = svgEditor,
|
{ svgCanvas } = svgEditor,
|
||||||
|
|
|
@ -7,15 +7,28 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { loadExtensionTranslation } from '../../locale.js';
|
|
||||||
|
|
||||||
const name = "grid";
|
const name = "grid";
|
||||||
|
|
||||||
|
const loadExtensionTranslation = async function (svgEditor) {
|
||||||
|
let translationModule;
|
||||||
|
const lang = svgEditor.configObj.pref('lang');
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line no-unsanitized/method
|
||||||
|
translationModule = await import(`./locale/${lang}.js`);
|
||||||
|
} catch (_error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.warn(`Missing translation (${lang}) for ${name} - using 'en'`);
|
||||||
|
// eslint-disable-next-line no-unsanitized/method
|
||||||
|
translationModule = await import(`./locale/en.js`);
|
||||||
|
}
|
||||||
|
svgEditor.i18next.addResourceBundle(lang, name, translationModule.default);
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name,
|
name,
|
||||||
async init ({ NS, getTypeMap }) {
|
async init ({ NS, getTypeMap }) {
|
||||||
const svgEditor = this;
|
const svgEditor = this;
|
||||||
await loadExtensionTranslation(svgEditor, name);
|
await loadExtensionTranslation(svgEditor);
|
||||||
const { svgCanvas } = svgEditor;
|
const { svgCanvas } = svgEditor;
|
||||||
const { $id } = svgCanvas;
|
const { $id } = svgCanvas;
|
||||||
const svgdoc = document.getElementById('svgcanvas').ownerDocument;
|
const svgdoc = document.getElementById('svgcanvas').ownerDocument;
|
||||||
|
|
|
@ -13,15 +13,28 @@
|
||||||
* will show the user the point on the canvas that was clicked on.
|
* will show the user the point on the canvas that was clicked on.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { loadExtensionTranslation } from '../../locale.js';
|
|
||||||
|
|
||||||
const name = "helloworld";
|
const name = "helloworld";
|
||||||
|
|
||||||
|
const loadExtensionTranslation = async function (svgEditor) {
|
||||||
|
let translationModule;
|
||||||
|
const lang = svgEditor.configObj.pref('lang');
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line no-unsanitized/method
|
||||||
|
translationModule = await import(`./locale/${lang}.js`);
|
||||||
|
} catch (_error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.warn(`Missing translation (${lang}) for ${name} - using 'en'`);
|
||||||
|
// eslint-disable-next-line no-unsanitized/method
|
||||||
|
translationModule = await import(`./locale/en.js`);
|
||||||
|
}
|
||||||
|
svgEditor.i18next.addResourceBundle(lang, name, translationModule.default);
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name,
|
name,
|
||||||
async init ({ _importLocale }) {
|
async init ({ _importLocale }) {
|
||||||
const svgEditor = this;
|
const svgEditor = this;
|
||||||
await loadExtensionTranslation(svgEditor, name);
|
await loadExtensionTranslation(svgEditor);
|
||||||
const { svgCanvas } = svgEditor;
|
const { svgCanvas } = svgEditor;
|
||||||
const { $id } = svgCanvas;
|
const { $id } = svgCanvas;
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -8,9 +8,22 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { loadExtensionTranslation } from "../../locale.js";
|
const name = "polystar";
|
||||||
|
|
||||||
const name = "polystar";
|
const loadExtensionTranslation = async function (svgEditor) {
|
||||||
|
let translationModule;
|
||||||
|
const lang = svgEditor.configObj.pref('lang');
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line no-unsanitized/method
|
||||||
|
translationModule = await import(`./locale/${lang}.js`);
|
||||||
|
} catch (_error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.warn(`Missing translation (${lang}) for ${name} - using 'en'`);
|
||||||
|
// eslint-disable-next-line no-unsanitized/method
|
||||||
|
translationModule = await import(`./locale/en.js`);
|
||||||
|
}
|
||||||
|
svgEditor.i18next.addResourceBundle(lang, name, translationModule.default);
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name,
|
name,
|
||||||
|
@ -21,7 +34,7 @@ export default {
|
||||||
let selElems;
|
let selElems;
|
||||||
let started;
|
let started;
|
||||||
let newFO;
|
let newFO;
|
||||||
await loadExtensionTranslation(svgEditor, name);
|
await loadExtensionTranslation(svgEditor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {boolean} on true=display
|
* @param {boolean} on true=display
|
||||||
|
|
|
@ -86,18 +86,3 @@ export const putLocale = async function (givenParam, goodLangs) {
|
||||||
console.info(`Lang: ${i18next.t('lang')}`);
|
console.info(`Lang: ${i18next.t('lang')}`);
|
||||||
return { langParam, i18next };
|
return { langParam, i18next };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const loadExtensionTranslation = async function (svgEditor, name) {
|
|
||||||
let translationModule;
|
|
||||||
const lang = svgEditor.configObj.pref('lang');
|
|
||||||
try {
|
|
||||||
// eslint-disable-next-line no-unsanitized/method
|
|
||||||
translationModule = await import(`./extensions/ext-${name}/locale/${lang}.js`);
|
|
||||||
} catch (_error) {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.warn(`Missing translation (${lang}) for ${name} - using 'en'`);
|
|
||||||
// eslint-disable-next-line no-unsanitized/method
|
|
||||||
translationModule = await import(`./extensions/ext-${name}/locale/en.js`);
|
|
||||||
}
|
|
||||||
svgEditor.i18next.addResourceBundle(lang, name, translationModule.default);
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in New Issue