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..aa25fcc14 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -1,10 +1,23 @@ const files = import.meta.glob(`./locale/*.yml`); +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); + }) + } }); } diff --git a/src/pages/Customer/locale/en.yml b/src/pages/Customer/locale/en.yml index 6eb7cfa85..67bfa6622 100644 --- a/src/pages/Customer/locale/en.yml +++ b/src/pages/Customer/locale/en.yml @@ -1,4 +1,4 @@ customerFilter: filter: - name: Name - socialName: Social name + name: 'Name' + socialName: 'Social name' diff --git a/src/pages/Customer/locale/es.yml b/src/pages/Customer/locale/es.yml index 8fed37092..ec1981257 100644 --- a/src/pages/Customer/locale/es.yml +++ b/src/pages/Customer/locale/es.yml @@ -1,4 +1,4 @@ customerFilter: filter: - name: Nombre - socialName: Razón Social + name: 'Nombre' + socialName: 'Razón Social'