add environment variable for changes lang

This commit is contained in:
cany748 2022-06-20 20:09:17 +07:00
parent f8c414042a
commit 2c29909ef6
6 changed files with 25 additions and 31 deletions

View file

@ -55,8 +55,6 @@ new Vue({
currentRelease: null,
latestRelease: null,
langDropdownShow: false,
chartOptions: {
chart: {
background: 'transparent',
@ -255,10 +253,6 @@ new Vue({
.catch(err => alert(err.message || err.toString()))
.finally(() => this.refresh().catch(console.error));
},
changeLang(lang) {
localStorage.setItem('lang', lang);
i18n.locale = lang;
},
},
filters: {
bytes,
@ -285,6 +279,12 @@ new Vue({
}, 1000);
Promise.resolve().then(async () => {
const lang = await this.api.getLang();
if (lang !== localStorage.getItem('lang') && i18n.availableLocales.includes(lang)) {
localStorage.setItem('lang', lang);
i18n.locale = lang;
}
const currentRelease = await this.api.getRelease();
const latestRelease = await fetch('https://weejewel.github.io/wg-easy/changelog.json')
.then(res => res.json())