Merge branch '6425-translationProposal' of https://gitea.verdnatura.es/verdnatura/salix-front into 6425-translationProposal
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
6a203f593f
|
@ -1,6 +1,7 @@
|
|||
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,
|
||||
|
@ -12,8 +13,9 @@ const i18n = createI18n({
|
|||
legacy: false,
|
||||
});
|
||||
|
||||
export default boot(({ app }) => {
|
||||
export default boot(async ({ app }) => {
|
||||
// Set i18n instance on app
|
||||
await locales();
|
||||
app.use(i18n);
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
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;
|
|
@ -1,23 +1,11 @@
|
|||
const files = import.meta.glob(`./locale/*.yml`);
|
||||
const modules = import.meta.glob(`../pages/**/locale/en.yml`);
|
||||
const translations = {};
|
||||
|
||||
for (const file in files) {
|
||||
const lang = file.split('/').at(2).split('.')[0];
|
||||
import(file)
|
||||
.then((t) => {
|
||||
translations[lang] = t.default;
|
||||
})
|
||||
.finally(() => {
|
||||
for (const module in modules) {
|
||||
const splittedFile = module.split('/');
|
||||
splittedFile.pop();
|
||||
const moduleFiles = splittedFile.join('/') + '/' + lang + '.yml';
|
||||
import(moduleFiles).then((t) => {
|
||||
Object.assign(translations[lang], t.default);
|
||||
});
|
||||
}
|
||||
});
|
||||
import(file).then((t) => {
|
||||
translations[lang] = t.default;
|
||||
});
|
||||
}
|
||||
|
||||
export const localeEquivalence = {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
customerFilter:
|
||||
filter:
|
||||
name: 'Name'
|
||||
socialName: 'Social name'
|
||||
name: Name
|
||||
socialName: Social name
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
customerFilter:
|
||||
filter:
|
||||
name: 'Nombre'
|
||||
socialName: 'Razón Social'
|
||||
name: Nombre
|
||||
socialName: Razón Social
|
||||
|
|
Loading…
Reference in New Issue