BlueMap/common/webapp/src/i18n.js
Lukas Rieger 1454297bbd
Rework gradle-build system (#574)
* Rework gradle-build setup

* Fix versioning

* Fix github build

* Configure publishing

* Push BlueMapAPI

* Reorganize project naming

* Update neoforge-gradle

* Add gradle-stracktrace to github action

* Remove clean gradle target to hopefully no longer upset neogradle for some reason

* Update gradle and add stacktrace to github action again

* Update neogradle

* Switch to neoforges ModDevGradle
2024-09-12 17:45:21 +02:00

38 lines
887 B
JavaScript

import {createI18n} from 'vue-i18n';
import {nextTick} from "vue";
import {fetchHocon} from "./js/Utils";
export const i18nModule = createI18n({
locale: 'none',
fallbackLocale: 'en',
silentFallbackWarn: true,
warnHtmlMessage: false,
legacy: false,
messages: {}
});
export const i18n = i18nModule.global;
export async function setLanguage(lang) {
try {
if (!i18n.availableLocales.includes(lang)){
let messages = await fetchHocon(`./lang/${lang}.conf`);
i18n.setLocaleMessage(lang, messages);
}
i18n.locale.value = lang;
document.querySelector('html').setAttribute('lang', lang);
} catch (e) {
console.error(`Failed to load language '${lang}'!`, e);
}
return nextTick();
}
export async function loadLanguageSettings() {
let settings = await fetchHocon(`./lang/settings.conf`);
i18n.languages = settings.languages;
await setLanguage(settings.default);
}