progress on localization

This commit is contained in:
JFH
2021-05-14 23:16:27 +02:00
parent 327a4bdc67
commit 1bad5b9037
16 changed files with 239 additions and 188 deletions

View File

@@ -86,3 +86,18 @@ export const putLocale = async function (givenParam, goodLangs) {
console.log(`Lang: ${i18next.t('lang')}`);
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);
};