I have changed my app to make it work with nuxt i18n and the translation seems to work when I access the routes directly.
E.g. http://localhost:3000/fr/step/1
I have the following structure in my app and each step is one page with different components inside.
My nuxt config:
In the documentation it says I need to add localePath
for my nuxt-links to make it work with the i18n plugin.
https://nuxt-community.github.io/nuxt-i18n/basic-usage.html#nuxt-link
For example:
<nuxt-link to="localePath('about')">About</nuxt-link>
In my app I used to navigate to the next step programmatically like:
this.$router.push({ path: `step/${this.currentStep + 1}` });
Now I have two problems (questions):
- How would I navigate to the route programmatically with
localePath
? For examplethis.localePath('step/2')
doesn't work. It redirects always to the frontpage. - Why is it not working with a normal link in the template? I have tested this:
<nuxt-link :to="localePath('step/2')">Foo</nuxt-link>
but it also doesn't work. When I try something like:<nuxt-link :to="localePath('success')">Foo</nuxt-link>
it works because thesuccess
page is on the first level.
It seems that there is something wrong in the routing or the way I handle the subpages. Can anyone help me with this?
<NuxtLink :to="$i18n.path('about')"
... – grindking