mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-01-15 12:51:38 +01:00
parent
7392447a35
commit
af2dad1d2f
@ -14,20 +14,24 @@ export const i18nModule = createI18n({
|
||||
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);
|
||||
}
|
||||
loadLanguage(lang);
|
||||
|
||||
i18n.locale.value = lang;
|
||||
|
||||
document.querySelector('html').setAttribute('lang', lang);
|
||||
|
||||
return nextTick();
|
||||
}
|
||||
|
||||
async function loadLanguage(lang) {
|
||||
try {
|
||||
if (!i18n.availableLocales.includes(lang)) {
|
||||
let messages = await fetchHocon(`./lang/${lang}.conf`);
|
||||
i18n.setLocaleMessage(lang, messages);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`Failed to load language '${lang}'!`, e);
|
||||
}
|
||||
|
||||
return nextTick();
|
||||
}
|
||||
|
||||
export async function loadLanguageSettings() {
|
||||
@ -51,6 +55,10 @@ export async function loadLanguageSettings() {
|
||||
selectedLanguage = settings.default;
|
||||
}
|
||||
|
||||
await loadLanguage('en');
|
||||
await loadLanguage(settings.default);
|
||||
i18nModule.global.fallbackLocale = [settings.default, 'en'];
|
||||
|
||||
i18n.languages = settings.languages;
|
||||
await setLanguage(selectedLanguage);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user