salix-front/src/i18n/index.js

33 lines
999 B
JavaScript

const langs = import.meta.glob(`./**/*.js`);
const files = import.meta.glob(`../pages/**/Translation/en.js`);
const importLang = {};
for (const fileLang in langs) {
const lang = fileLang.split('/').at(1);
import(fileLang)
.then((t) => {
importLang[lang] = t.default;
})
.finally(() => {
for (const file in files) {
const splittedFile = file.split('/');
splittedFile.pop();
const langFiles = splittedFile.join('/') + '/' + lang + '.js';
console.log('myFile: ', langFiles);
import(langFiles)
.then((t) => {
Object.assign(importLang[lang], t.default);
})
.catch((err) => {
console.log('no va: ' + err, file, importLang);
});
}
});
}
export const localeEquivalence = {
en: 'en-GB',
};
export default importLang;