18 lines
597 B
JavaScript
18 lines
597 B
JavaScript
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;
|