From 73c5a5b7d25bc69d069a3b8e211f7568ba37dcba Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 16 Apr 2024 11:00:38 +0200 Subject: [PATCH] fix: refs #6425 fixed dev translations --- src/boot/i18n.js | 4 +--- src/i18n/handle.js | 17 ----------------- src/i18n/index.js | 20 ++++++++++++++++++-- 3 files changed, 19 insertions(+), 22 deletions(-) delete mode 100644 src/i18n/handle.js diff --git a/src/boot/i18n.js b/src/boot/i18n.js index ede8f5114..b23b6d5fd 100644 --- a/src/boot/i18n.js +++ b/src/boot/i18n.js @@ -1,7 +1,6 @@ import { boot } from 'quasar/wrappers'; import { createI18n } from 'vue-i18n'; import messages from 'src/i18n'; -import { locales } from 'src/i18n/handle'; const i18n = createI18n({ locale: navigator.language || navigator.userLanguage, @@ -13,9 +12,8 @@ const i18n = createI18n({ legacy: false, }); -export default boot(async ({ app }) => { +export default boot(({ app }) => { // Set i18n instance on app - await locales(); app.use(i18n); }); diff --git a/src/i18n/handle.js b/src/i18n/handle.js deleted file mode 100644 index 331b60b71..000000000 --- a/src/i18n/handle.js +++ /dev/null @@ -1,17 +0,0 @@ -const modules = import.meta.glob(`../pages/**/locale/**.yml`); -import translations from './index'; -const LOCALE_EXTENSION = '.yml'; - -export async function locales() { - for await (const module of Object.keys(modules)) { - const splittedFile = module.split('/'); - const lang = splittedFile.pop().split(LOCALE_EXTENSION)[0]; - const moduleFiles = splittedFile.join('/') + '/' + lang + LOCALE_EXTENSION; - import(moduleFiles).then((t) => { - Object.assign(translations[lang], t.default); - }); - } - return translations; -} - -export default translations; diff --git a/src/i18n/index.js b/src/i18n/index.js index d94f77bb2..a0b4c44bd 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -1,10 +1,26 @@ const files = import.meta.glob(`./locale/*.yml`); +console.log('files: ', files); +const modules = import.meta.glob(`../pages/**/locale/*.yml`); + const translations = {}; + for (const file in files) { const lang = file.split('/').at(2).split('.')[0]; - import(file).then((t) => { - translations[lang] = t.default; + + files[file]() + .then((g) => { + translations[lang] = g.default; + }) + .finally(() => { + const actualLang = lang + '.yml'; + for (const module in modules) { + if (!module.endsWith(actualLang)) continue; + modules[module]().then((t) => { + Object.assign(translations[lang], t.default); + console.log(' modules[module].default: ', t.default); + }) + } }); }