0👍
✅
My issue was that I wasn’t even commiting any mutation in language change function so I didn’t change value in vuex storage actually I was only changing value in component which was re-rendering selected flag.
So after changing mutations to:
mutations: {
changeLang: (state, response) => {
if(response) {
state.currentLanguage = response;
}
}
},
and in function which is changing language i commit this mutation:
changeLanguage(lang) {
Vue.i18n.set(lang);
this.selectedLanguage = lang;
this.$store.commit('changeLang', lang);
}
And now everything works fine. At first load language is browser language after user change it and refresh it stay changed.
Source:stackexchange.com