mirror of
https://github.com/BlueMap-Minecraft/BlueMapVue.git
synced 2025-01-05 22:57:34 +01:00
Fix language switching does not load the language
This commit is contained in:
parent
5ed5e21896
commit
14105db263
@ -43,7 +43,7 @@
|
||||
<Group v-if="$i18n.languages.length > 1" :title="$t('language.title')">
|
||||
<SimpleButton v-for="lang of $i18n.languages" :key="lang.locale"
|
||||
:active="lang.locale === $i18n.locale"
|
||||
@action="$i18n.locale = lang.locale; $bluemap.saveUserSettings();"
|
||||
@action="$i18n.setLanguage(lang.locale); $bluemap.saveUserSettings();"
|
||||
>{{lang.name}}</SimpleButton>
|
||||
</Group>
|
||||
|
||||
|
@ -3,18 +3,18 @@ import Vue from 'vue';
|
||||
import fallback from './fallback';
|
||||
|
||||
VueI18n.prototype.setLanguage = async function(lang) {
|
||||
if (!this.messages[lang]){
|
||||
try {
|
||||
try {
|
||||
if (!this.messages[lang]){
|
||||
let messages = {};
|
||||
messages = (await import(/* webpackIgnore: true */ `../lang/${lang}.js`)).default;
|
||||
|
||||
this.setLocaleMessage(lang, messages);
|
||||
|
||||
this.locale = lang;
|
||||
document.querySelector('html').setAttribute('lang', lang);
|
||||
} catch (e) {
|
||||
console.error(`Failed to load language '${lang}'!`, e);
|
||||
}
|
||||
|
||||
this.locale = lang;
|
||||
document.querySelector('html').setAttribute('lang', lang);
|
||||
} catch (e) {
|
||||
console.error(`Failed to load language '${lang}'!`, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ const vue = new Vue({
|
||||
}).$mount('#app');
|
||||
|
||||
// load languages
|
||||
i18n.loadLanguageSettings();
|
||||
i18n.loadLanguageSettings().catch(error => console.error(error));
|
||||
|
||||
// load bluemap next tick (to let the assets load first)
|
||||
vue.$nextTick(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user