Skip to content

Composition API: Access i18n local in vue-router #574

Answered by gagarine
gagarine asked this question in Q&A
Discussion options

You must be logged in to vote

The i18n.global.locale and i18n.global.fallbackLocale seem to be reactive property similar that when you use ref() in your setup function. Therefor you need to add .value to access their value.

import { i18n } from '../plugins/i18n.plugin';

const currentLang = i18n.global.locale.value
const fallbackLocale = i18n.global.fallbackLocale.value

// use meta: { requiresAuth: true } to require a logged in user
const routes = [
  {
    path: '/',
    redirect: `/${currentLang}`
  },
  {
    path: '/:locale',
    component: LocaleRoute,

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gagarine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant