Fix language switching does not load the language

This commit is contained in:
Blue (Lukas Rieger) 2021-03-21 11:39:09 +01:00
parent 5ed5e21896
commit 14105db263
No known key found for this signature in database
GPG Key ID: 904C4995F9E1F800
3 changed files with 9 additions and 9 deletions

View File

@ -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>

View File

@ -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);
}
}

View File

@ -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(() => {