-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
Translatable Routes Fail When Using Customizing the Key for translatable parameters #924
Comments
Hello, I just solved the error that the package presents with the translations of the selected "slug" when using Route Model Binding. The error is simple to reproduce. In my case, I was using the language resource files of 'routes.php' to translate the routes up to the first parameter. Following the official Laravel documentation to use Route Model Binding, I only had to define the route translations this way:
Of course, when using this but with the extra of selecting which model field to use as the 3rd parameter of the URL, the package did not detect it and could not resolve it, returning the route like this:
First of all, I experience this error when I want to translate the current URL using the language-switcher I developed, where I use the function
This works to solve when you only have one use of Route Model Binding in the route, but the Laravel documentation allows you to have multiple bindings in the same URL, so further investigation is needed to see if this can also be resolved. Example from the documentation for multiple bindings in the same URL:
I hope my contribution helps improve the package for the community 😁✌️. |
In a fresh Laravel 11 application using LaravelLocalization, translatable routes work as expected with:
routes.php
However, customizing the key for a translatable route causes the route to fail.
Example
Calling
localhost/users/bernd
won't resolve, even if a user with slugbernd
is in db.The text was updated successfully, but these errors were encountered: