-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support passing path to localePath for easier resolving of dynamic routes #215
Comments
I found this information to be very useful for decoupling my CMS and serving content with Nuxt. I'm using the slightly less awkward syntax I'd like to add that you must add your default locale last to the locales definition when using the
So you get the following routes generated for your
Else your localized dynamic route never matches. |
Indeed. It's #152 |
Yes, that would be really nice to have! |
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. |
Makes sense to support it IMO. |
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. |
What problem does this feature solve?
localePath
takes either string or object.String is expected to be route's internal name.
Object, with current implementation of
localePath
, will be passed to VueRouter's resolve function but thename
property will get___[locale]
appended to it.The problem is that the object variant expects
name
to be set, otherwise it will createname
value likeundefined___[locale]
and route will not match.Given that it won't work to pass an object with just
{path: '/about'}
, for dynamic routes likepages/_.vue
, we must instead do an awkward localePath call likelocalePath({name: 'all', params: {0: 'about'}})
(haven't really tested but I think it should work). This is IMO too cumbersome and what's more, it requires knowledge of internal route's name. It's basically not user friendly.What does the proposed changes look like?
It should be possible to call code below to get localized path to dynamic route
and let router figure out the path.
Note that with PREFIX_AND_DEFAULT mode, it should ideally only return path with locale prefix added, if resolving to non-default language OR when current route includes locale prefix.
So (with
en
being default locale):/about
>> localePath({path: '/about'}) >>/about
/en/about
>> localePath({path: '/about'}) >>/en/about
/fr/about
>> localePath({path: '/about'}) >>/fr/about
The text was updated successfully, but these errors were encountered: