-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
When trailingSlash: true
, createLocalizedNavigation
doesn't work properly
#668
Comments
For me this works without an issue. Can you submit a reproduction that shows the error? |
Thank you for your report. Unfortunately, the reproduction is missing or incomplete, and as such we cannot investigate this issue. Please add a reproduction to the issue, otherwise it will be closed automatically. Templates: Creating a good bug report takes time. To help us resolve the issue quickly, please simplify the reproduction as much as possible by removing any unnecessary code, files, and dependencies that are not directly related to the problem. The easier it is for us to see the issue, the faster we can help you. Apart from the reproduction, make sure to include the precise steps on how to reproduce the issue, e.g.:
Thank you for your understanding! FAQ"I've included a reproduction, what is missing?" This comment might have been added because your reproduction doesn't point to either a CodeSandbox or a public GitHub repository where the issue can be reproduced. Please make sure:
|
When moving this to codesandbox I somehow can only reproduce half of the problem which are the trailing slashes in the config file. The homepage error doesn't happen there. Let me know if you can open the codesandbox, it's my first time using it |
I can access the CSB, yes! I can see these errors:
Are these the ones which you are seeing too? Generally, maybe we could adapt the internal handling to work both with trailing slashes and without. If you're interested in working on a fix, here's the relevant code:
Also see the contributors guide. |
trailingSlash: true
, createLocalizedNavigation
doesn't work properly
@amannn Hello! I noticed a problem for navigation with this: the localized path is taken from the object by the key (current pathname). The current pathname is a pathname without a slash at the end ( There are several ways to solve this: Check if trailing slash is included and if yes - make pathname with a slash at the end, if not - without. The downside here is that the user is limited by this and needs to know this detail. Ignore this issue and write in the doc that all keys must be without a slash at the end (except for the root page) Bring the object of localized pathnames and current pathname to one form - f.e. without a slash at the end (current pathname |
Description
The language switcher doesn't work on homepage when trailingSlash is set to true in next.config.js
Also, the pathnames param sent to the createLocalizedPathnamesNavigation() function, has to have no-trailing slash, to work regardless of the trailingSlash setting in next.config.js. This is just ok, just annoying, maybe it can be fixed alongside the homepage problem.
Mandatory reproduction URL (CodeSandbox or GitHub repository)
https://github.com/amannn/next-intl/tree/main/examples/example-app-router
Reproduction description
Steps to reproduce:
Expected behaviour
Setting trailingSlash to true, should keep all translation mechanisms intact.
The text was updated successfully, but these errors were encountered: