Closed rubenmeines closed 5 years ago
This issue as been imported as question since it does not respect nuxt-i18n issue template. Only bug reports and feature requests stays open to reduce maintainers workload. If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically. Your question is available at https://cmty.app/nuxt/nuxt-i18n/issues/c327.
I have the exact same issue re open please.
I have two routes that have exactly the same code.
expertises/_slug blog/_articleId
the code is
async asyncData(ctx) {
try {
const article = await getStories(ctx, `/blog/${ctx.params.articleId}`) // for expertise
const story = article.data.story
const slugs = {
en: { slug: story.slug },
}
story.translated_slugs.forEach((t) => {
const tmp = t.path.split('/')
slugs[t.lang] = { slug: tmp[tmp.length - 1] }
})
// in both case the slugs is
/*
{
en: {slug: 'routeNameEN'},
fr: {slug: 'routeNameFR'},
}
*/
await ctx.store.dispatch('i18n/setRouteParams', slugs)
return {
story,
}
} catch (e) {
ctx.error('not found')
}
}
The weird thing is that the dispatch is called with the good params. and the state looks good too. So it should work it's like in this case the switch local Path didnt have the infos on time.
I can't put it in public but i can give access to the project. In one case its working well when i use switchLocalePath it redirect to the translated url.
Ok no matter if i am using switchLocalPath when clicking so it's not immediately execute. It's not working. it stay with the first route name he has
It's better to create a separate issue. Especially since yours doesn't seem related to the initial one which was about having untranslated routes.
It would help if you would create a minimal project that reproduces it as I don't have much time to do it myself.
same issue
Hi,
Situation: I have a site with 2 languages (dutch and english). I am using the language switcher and the switchLocalePath function inside nuxt-link. However, not all of my pages have been translated.
Current situation: I am using dynamic links ('/recipes/:slug') when I click on the translation of a page, which I have not translated yet, it will just go to the new locale and paste the slug of the previous language.
Ideal situation: Be able to manipulate the link generated by "switchLocalePath()" so I can just lead it to the homepage of the clicked/desired language inside the language switcher.
For example: If i have a slug for the dutch translation right now I can dispatch using:
store.dispatch('i18n/setRouteParams', { nl: { slug: 'spaghetti-carbonara' } });
else (not possible): Use another dispatch to Go to dutch home page.Does anyone know if this is already possible or if there is a solution?