diff --git a/src/App.vue b/src/App.vue index 36b30131..a2252474 100644 --- a/src/App.vue +++ b/src/App.vue @@ -176,6 +176,7 @@ export default { return this.$route.fullPath; }, ...mapState({ + language: state => state.gui.general.language, isConnected: state => state.socket.isConnected, hostname: state => state.printer.hostname, apiHost: state => state.socket.hostname, @@ -372,6 +373,9 @@ export default { } }, watch: { + language(){ + this.$i18n.locale = this.language; + }, print_percent() { this.drawFavicon(this.print_percent); }, diff --git a/src/components/panels/Settings/LanguagePanel.vue b/src/components/panels/Settings/LanguagePanel.vue index 51d46210..100d14f9 100644 --- a/src/components/panels/Settings/LanguagePanel.vue +++ b/src/components/panels/Settings/LanguagePanel.vue @@ -42,18 +42,16 @@ computed: { lang: { get() { - return localStorage.getItem("lang"); - // return this.$store.state.gui.general.language; + return this.$store.state.gui.general.language; }, - set(language){ - return localStorage.setItem("lang",language); - // return this.$store.dispatch('gui/setSettings', { general: { language: language } }); + set(newVal){ + return this.$store.dispatch('gui/setSettings', { general: { language: newVal } }); } } }, methods: { changeLanguage(val){ - this.$i18n.locale = this.lang = val + this.lang = val } } } diff --git a/src/plugins/i18n.js b/src/plugins/i18n.js index d73130b7..b9d8aac5 100644 --- a/src/plugins/i18n.js +++ b/src/plugins/i18n.js @@ -14,13 +14,9 @@ function loadLocaleMessages () { }) return messages } - - let lang = localStorage.getItem("lang") || 'en' - - localStorage.setItem("lang",lang); export default new VueI18n({ - locale: process.env.VUE_APP_I18N_LOCALE || lang, - fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || lang, + locale: process.env.VUE_APP_I18N_LOCALE || 'en', + fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', messages: loadLocaleMessages() }) \ No newline at end of file