diff --git a/frontend/src/components/LanguageSwitch.vue b/frontend/src/components/LanguageSwitch.vue index 0905bb3af..2b160b3e3 100644 --- a/frontend/src/components/LanguageSwitch.vue +++ b/frontend/src/components/LanguageSwitch.vue @@ -21,12 +21,14 @@ export default { data() { return { locales: locales, + currentLanguage: {}, } }, methods: { - async setLocale(locale) { + setLocale(locale) { this.$i18n.locale = locale this.$store.commit('language', this.$i18n.locale) + this.currentLanguage = this.getLocaleObject(locale) localeChanged(locale) }, async saveLocale(locale) { @@ -52,9 +54,7 @@ export default { if (lang) return lang.split('-')[0] return lang }, - }, - computed: { - currentLanguage() { + setCurrentLanguage() { let locale = this.$store.state.language || this.getNavigatorLanguage() || 'en' let object = this.getLocaleObject(locale) if (!object) { @@ -62,8 +62,11 @@ export default { object = this.getLocaleObject(locale) } this.setLocale(locale) - return object + this.currentLanguage = object }, }, + created() { + this.setCurrentLanguage() + }, } diff --git a/frontend/src/views/Layout/ContentFooter.spec.js b/frontend/src/views/Layout/ContentFooter.spec.js index 013ec8244..8d0c6dfbd 100644 --- a/frontend/src/views/Layout/ContentFooter.spec.js +++ b/frontend/src/views/Layout/ContentFooter.spec.js @@ -12,9 +12,6 @@ describe('ContentFooter', () => { locale: 'en', }, $t: jest.fn((t) => t), - $store: { - commit: jest.fn(), - }, } const Wrapper = () => { diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js index 8c1e604c0..84c955042 100644 --- a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js +++ b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js @@ -44,6 +44,9 @@ describe('DashboardLayoutGdd', () => { const store = new Vuex.Store({ state, + mutations: { + language: jest.fn(), + }, }) const Wrapper = () => {