@leonils Use this package https://github.com/mcamara/laravel-localization
It's really helpful.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Good afternoon.
I actually work on a multilingual website. I really enjoy how laravel deals with that. It's make things really pleasant. However, I'm facing difficulties to translate my routes. I would like url as
mywebsite.com/en/applications in englishmywebsite.com/fr/candidatures in frenchSo I write files in lang/fr/routes.php, and so in languages I want to support :
return [
'applications' => 'candidatures',
];
Then in my RouteServiceProvider, il add in mapWebRoutes()
Route::middleware('web', 'setlocale')
->namespace($this->namespace)
->prefix('{locale}')
->where(['locale' => '[a-zA-Z]{2}'])
->group(base_path('routes/web.php'));
With setlocale a middleware containing:
public function handle($request, Closure $next)
{
app()->setLocale($request->segment(1));
return $next($request);
}
So now, I would espect use the routes
Route::resource(Lang::get('routes.applications'), 'ApplicationController');
As I already verified than Lang::get('routes.applications') give me "candidature" if I am on french part. But there, I have a 404 error I cant explain. If I add this to my web.php :
Route::get('/', function () {
var_dump(Lang::get('routes.applications'));
});
It give me "candidatures", and Route::resource('candidatures', 'ApplicationController'); lead me at the right place. But Route::resource(Lang::get('routes.applications'), 'ApplicationController'); don't...
Thank you a lot for your help !
@leonils Use this package https://github.com/mcamara/laravel-localization
It's really helpful.
Please or to participate in this conversation.