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 const i18n = i18nModule.global;
|
||||||
|
|
||||||
export async function setLanguage(lang) {
|
export async function setLanguage(lang) {
|
||||||
try {
|
loadLanguage(lang);
|
||||||
if (!i18n.availableLocales.includes(lang)){
|
|
||||||
let messages = await fetchHocon(`./lang/${lang}.conf`);
|
|
||||||
i18n.setLocaleMessage(lang, messages);
|
|
||||||
}
|
|
||||||
|
|
||||||
i18n.locale.value = lang;
|
i18n.locale.value = lang;
|
||||||
|
|
||||||
document.querySelector('html').setAttribute('lang', 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) {
|
} catch (e) {
|
||||||
console.error(`Failed to load language '${lang}'!`, e);
|
console.error(`Failed to load language '${lang}'!`, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nextTick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadLanguageSettings() {
|
export async function loadLanguageSettings() {
|
||||||
@ -51,6 +55,10 @@ export async function loadLanguageSettings() {
|
|||||||
selectedLanguage = settings.default;
|
selectedLanguage = settings.default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await loadLanguage('en');
|
||||||
|
await loadLanguage(settings.default);
|
||||||
|
i18nModule.global.fallbackLocale = [settings.default, 'en'];
|
||||||
|
|
||||||
i18n.languages = settings.languages;
|
i18n.languages = settings.languages;
|
||||||
await setLanguage(selectedLanguage);
|
await setLanguage(selectedLanguage);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user