Skip to content
Snippets Groups Projects
Commit e66ef5fd authored by simon.mellerin's avatar simon.mellerin
Browse files

Locale - fix on locale options in top menu bar

parent 614aeb59
No related branches found
No related tags found
1 merge request!39Locale - fix on locale options in top menu bar
Pipeline #10370 passed
......@@ -16,8 +16,9 @@ import Button from 'primevue/button'
import Menubar from 'primevue/menubar'
import { useRoute, useRouter } from 'vue-router'
import OcLink from '@/components/OcLink.vue'
import { availableLocales } from '@/i18n'
const { availableLocales, locale, t } = useI18n()
const { locale, t } = useI18n()
const route = useRoute()
const router = useRouter()
......@@ -37,19 +38,16 @@ const menu = ref()
const menuItems = computed(() => {
const localeItems: MenuItem[] = []
const localeLabels = {
en: 'English',
fr: 'Français'
}
for (const availableLocale of availableLocales) {
for (const key in availableLocales) {
localeItems.push({
label: localeLabels[availableLocale as keyof typeof localeLabels],
label: availableLocales[key],
command: () => {
router.push({
name: route.name,
params: {
...route.params,
lang: availableLocale
lang: key
}
})
}
......
......@@ -3,6 +3,11 @@ import messageEn from './locales/en'
import messageFr from './locales/fr'
import { setLocale as setYupLocale } from 'yup';
export const availableLocales: { [key: string]: string } = {
en: 'English',
fr: 'Français'
}
const i18n = createI18n({
legacy: false,
locale: 'en',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment