From 92185feaf452e15e48ce09340d0a3c29f3c8dbde Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Wed, 27 Aug 2025 14:01:58 +0200 Subject: [PATCH] Enabled i18n support in vuetify --- frontend/src/plugins/vuetify.js | 40 +++++++++++++++++++++++++++++++ frontend/src/stores/auth.store.js | 13 ++++++---- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/frontend/src/plugins/vuetify.js b/frontend/src/plugins/vuetify.js index 2a2881f39..bed3f6d76 100644 --- a/frontend/src/plugins/vuetify.js +++ b/frontend/src/plugins/vuetify.js @@ -7,6 +7,24 @@ // Styles import '@mdi/font/css/materialdesignicons.css' import 'vuetify/styles' +import { + cs, + de, + el, + en, + es, + fi, + fr, + it, + ja, + nl, + pl, + pt, + ru, + sv, + tr, + zhHans, +} from 'vuetify/locale' // Composables import { createVuetify } from 'vuetify' @@ -26,6 +44,28 @@ export default createVuetify({ }, }, }, + locale: { + locale: 'en', + fallback: 'en', + messages: { + cs, + de, + el, + en, + es, + fi, + fr, + it, + ja, + nl, + pl, + pt, + ru, + sv, + tr, + zhHans, + }, + }, styles: { configFile: 'src/styles/settings.scss' }, defaults: { VCard: { diff --git a/frontend/src/stores/auth.store.js b/frontend/src/stores/auth.store.js index 5b65a4e7e..236a7952b 100644 --- a/frontend/src/stores/auth.store.js +++ b/frontend/src/stores/auth.store.js @@ -3,6 +3,7 @@ import Cookies from 'js-cookie' import { defineStore } from 'pinia' import { computed, inject, ref } from 'vue' import gettext from '@/plugins/gettext' +import { useLocale } from 'vuetify' import router from '@/router/index.js' import { UserManager } from 'oidc-client-ts' @@ -19,6 +20,7 @@ export const useAuthStore = defineStore('auth', () => { const isAuthenticated = ref(false) let redirectUri = getAbsoluteUrl(config.OAUTH_REDIRECT_URI) let postLogoutRedirectUri = getAbsoluteUrl(config.OAUTH_POST_REDIRECT_URI) + const { current } = useLocale() const manager = new UserManager({ authority: config.OAUTH_AUTHORITY_URL, @@ -48,11 +50,11 @@ export const useAuthStore = defineStore('auth', () => { }) async function fetchUser() { - return accountApi.getMe().then((resp) => { - authUser.value = resp.data - gettext.current = accountLanguage.value - isAuthenticated.value = true - }) + const resp = await accountApi.getMe() + authUser.value = resp.data + gettext.current = accountLanguage.value + current.value = accountLanguage.value + isAuthenticated.value = true } async function getFidoCreds() { @@ -169,6 +171,7 @@ export const useAuthStore = defineStore('auth', () => { authUser.value = { ...newAuthUser } if (accountLanguage.value in gettext.available) { gettext.current = accountLanguage.value + current.value = accountLanguage.value } }) }