-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
RFC: Localization of pathnames and streamlining of navigation APIs #402
Comments
See also vercel/next.js#49761 |
I've started working on a proof-of-concept for this! |
Update: This is available as of |
@amannn This really helps me removing my own version of this in my middleware 🎉 |
@TommySorensen Great to hear! 🙌 The pathnames for the middleware can be fetched async if you compose the middleware. As for the corresponding navigation APIs, you might not have a benefit there, because the point of them is really the static typing (which doesn't apply to your use case). How do you solve this currently? Do you provide wrappers for navigation APIs yourself that are based on CMS data? |
This has been fully implemented in the 3.0 RC (see announcement) |
I'd imagine many people would use resource id's as their pathname key, as opposed to the default locale pathname. When getting dynamic data, a lot of cms api's will not let you query for a pathname that is different than the requested locale. Since it seems that rewrites are used, the param passed to a page component will only ever be the pathname's key and it fails to provide the localized pathname to the page params. When using default locale, it will often times ignore the localized pathname value and just display the pathname's object key. It seems like an optimistic assumption and in my opinion, would be much better to always prioritize the current locale, if available, rather than the pathname key. tldr: I believe the pathname's key should never be shown in the url bar, if a localized version exists within the object. |
@HarleySalas Do you think you could include some concrete examples that demonstrate your use case? It's a bit hard for me to follow since the terminology is quite broad. |
→ Please refer to [the announcement](https://next-intl-docs.vercel.app/blog/next-intl-3-0) Fixes #488 Fixes #402 Fixes #578 --------- Co-authored-by: 汪心禾 <[email protected]> Co-authored-by: Tobias <[email protected]> Co-authored-by: Andres <[email protected]> Co-authored-by: Andres <[email protected]> Co-authored-by: narakhan <[email protected]> Co-authored-by: Nicholas Mobbs <[email protected]> Co-authored-by: James Berry <[email protected]> Co-authored-by: Brendon Sled <[email protected]>
Localization of pathnames
Update: This is available as of
[email protected]
, see the announcement thread.We currently provide minimal documentation for localizing pathnames (see also the named routes example).
It would be helpful to have built-in support for this.
We could achieve this by accepting a route map:
Proposed docs:
Prior art: https://v8.i18n.nuxtjs.org/guide/custom-paths
Streamlining of navigation APIs
Similar to the proposed factory function
createLocalizedPathnamesNavigation
, we could offer acreateSharedPathnamesNavigation
factory function that can be used to create the currently existing navigation APIs for non-localized pathnames.This would:
Potentially we could furthermore return a typed version of
useLocale
from these functions.Rollout plan: Introduce
createSharedPathnamesNavigation
in a minor version, deprecate the previous imports and remove them in a major release.The text was updated successfully, but these errors were encountered: