Replies: 2 comments 1 reply
-
|
Wayfinder generates its route helpers from your Laravel named routes at build time — it doesn't have its own concept of locale. The key insight is: Wayfinder just calls whatever URL your named route resolves to, so you need the locale prefix baked into the route name resolution on the PHP side first, then Wayfinder picks it up automatically. Here's the approach that satisfies all four of your requirements without any third-party localization package: 1. Define localized route groups in
|
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the detailed response! I’ll check that out tomorrow |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm trying to get localized routes to work using the Laravel React starter kit that has changed from Ziggy to Wayfinder since I last used it but can't get it to work. Does anyone here know how I should go about doing this if it's possible? My goal is that the following requirements should be met:
route()method and similar should also link to the current localeI've currently tried https://github.com/mcamara/laravel-localization which I couldn't make work with Wayfinder at all. I've also tried manual
Route::prefix('{locale?}')groups in conjunction with Fortify config'prefix' => '{locale?}'but that didn't work either. I'm either having issues with /{route} not working (404) while /{locale}/{route} does work or wise versa in conjunction with Wayfinder not being able to produce correct urls. I could sort of get the route prefix version to work in the sense thatsetUrlDefaultspassed the correct locale for links etc but then I got an issue with the default locale where all links became //{route} rather than /{route}.I've also tried utilizing Laravel Boost and ask Copilot to help me but it also gets stuck with the fact that link become //{route} rather than /{route}.
I did see another discussion regarding this where the localization package named above was used which ended with them reverting back to Ziggy.
Is it possible to achieve this with or without the localization package or do I have to revert back to using Ziggy? I'd really like to get it working since Wayfinder is used "everywhere" within the starter kit which I still want to utilize.
Any help and/or suggestions are greatly appreciated
Beta Was this translation helpful? Give feedback.
All reactions