[Vuejs]-$i18n Locale get changed when navigating

2👍

finally i got this is answer :

<nuxt-link :to="localePath('/home')"> home </nuxt-link>

1👍

For create route path use

method this.localePath(...), ctx.app.localePath(...)

only this method prepare path with current locale or you can do this himself

0👍

For people who are dealing with this in nuxt3 with locale cookie, try

<script setup>
const localeRoute = useLocaleRoute()
const { locale } = useI18n()
const linkPath = computed(() => {
  const route = localeRoute('blog', locale.value)
  return route != null ? route.path : '/'
})
</script>

<template>
  <NuxtLink :to="linkPath">{{ $t('blog') }}</NuxtLink>
</template>

found in https://v8.i18n.nuxtjs.org/api/composables

Leave a comment