i18n icon indicating copy to clipboard operation
i18n copied to clipboard

setRouteParams should also control if the route is valid or not

Open yakovyarmo opened this issue 3 years ago • 3 comments

Hi, We are in a situation where some of our pages are translated and some are not. It would really help if there was a way to disable the route using setRouteParams.

yakovyarmo avatar Dec 19 '21 14:12 yakovyarmo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 02 '22 09:03 stale[bot]

I think it makes sense to call context.error in this case, without using setRouteParams.

rchl avatar Mar 02 '22 09:03 rchl

I would also love to see this feature. Currently, I am fetching the content in setup() (GraphQL) which returns a list in which locales the content is available, the route slugs are dynamic for each locale too.

Example /en/blog/:slug

The current behaviour is that non translated pages are still showing the the alternative links in <head> and locales on the locale selector, which results in 404 because the slugs are wrong for non-existing languages.

Disabling it with https://i18n.nuxtjs.org/ignoring-localized-routes is not working since the decision if that specific entry is available or not happens during the rendering and not on a per page component basis.

Something like the following would really help with solving this:

   await $store.dispatch('i18n/setRouteParams', {
     de: { slug: 'eintrag123' },
     en: { slug: 'entry123' },
     ja: false,
   });

BirknerAlex avatar Mar 28 '22 13:03 BirknerAlex