feat(i18n): add ui localization (#2279)

Co-authored-by: TheElixZammuto <6505622+TheElixZammuto@users.noreply.github.com>
This commit is contained in:
ReenigneArcher
2024-03-22 19:54:12 -04:00
committed by GitHub
parent 8316f44e10
commit 87774333f3
29 changed files with 4446 additions and 719 deletions

View File

@@ -0,0 +1,27 @@
import {createI18n} from "vue-i18n";
// Import only the fallback language files
import en from './public/assets/locale/en.json'
export default async function() {
let r = await (await fetch("/api/configLocale")).json();
let locale = r.locale ?? "en";
document.querySelector('html').setAttribute('lang', locale);
let messages = {
en
};
try {
if (locale !== 'en') {
let r = await (await fetch(`/assets/locale/${locale}.json`)).json();
messages[locale] = r;
}
} catch (e) {
console.error("Failed to download translations", e);
}
const i18n = createI18n({
locale: locale, // set locale
fallbackLocale: 'en', // set fallback locale
messages: messages
})
return i18n;
}