From d265163fbe81f6df8530345c72567a88ca8ec9f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Viricel?= Date: Tue, 12 Mar 2024 18:09:18 +0100 Subject: [PATCH] feat: add i18n support to vuetify #194 --- components/MainMap/NavMenu.vue | 11 ++++++++++- plugins/vuetify.ts | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/components/MainMap/NavMenu.vue b/components/MainMap/NavMenu.vue index 59fe63de2..a8aff19d4 100644 --- a/components/MainMap/NavMenu.vue +++ b/components/MainMap/NavMenu.vue @@ -6,7 +6,7 @@ import type { LocaleObject } from 'vue-i18n-routing' import { VDivider } from 'vuetify/components/VDivider' import { VList, VListItem, VListItemTitle } from 'vuetify/components/VList' import { VMenu } from 'vuetify/components/VMenu' - +import { useLocale } from 'vuetify' import { defineNuxtComponent } from '#app' import ExternalLink from '~/components/UI/ExternalLink.vue' import IconButton from '~/components/UI/IconButton.vue' @@ -34,6 +34,14 @@ export default defineNuxtComponent({ }, }, + setup() { + const { current } = useLocale() + + return { + vuetifyLocale: current, + } + }, + computed: { ...mapWritableState(siteStore, ['locale']), @@ -46,6 +54,7 @@ export default defineNuxtComponent({ async setLocale(locale: string) { await this.$i18n.setLocale(locale) this.locale = locale + this.vuetifyLocale = locale }, openLink(title: string, url: string) { this.$tracking({ diff --git a/plugins/vuetify.ts b/plugins/vuetify.ts index cbe8b7351..9b98c584a 100644 --- a/plugins/vuetify.ts +++ b/plugins/vuetify.ts @@ -1,11 +1,17 @@ import { createVuetify } from 'vuetify' import { aliases, mdi } from 'vuetify/iconsets/mdi-svg' +import { en, es, fr } from 'vuetify/locale' import 'vuetify/styles' import { defineNuxtPlugin } from '#app/nuxt' export default defineNuxtPlugin((nuxtApp) => { const vuetify = createVuetify({ + locale: { + locale: 'en', + fallback: 'en', + messages: { en, es, fr }, + }, icons: { defaultSet: 'mdi', aliases,