chinleung/laravel-multilingual-routes
Register multilingual Laravel routes automatically from a single definition. Generates locale-prefixed URLs (optionally including default locale) and can auto-detect/set locale via middleware. Configure supported locales and keep route naming consistent across languages.
composer require chinleung/laravel-multilingual-routes.DetectRequestLocale middleware to the top of your web middleware group in bootstrap/app.php to automatically detect and switch the app locale per request.app.locales config or use chinleung/laravel-locales.php artisan vendor:publish --provider="ChinLeung\MultilingualRoutes\MultilingualRoutesServiceProvider" --tag="config" to publish config if you need to prefix the default locale.Route::multilingual('/', 'HomeController')->name('home');, then create translation files at resources/lang/{locale}/routes.php (e.g., 'home' => 'accueil' for French).Route::multilingualResource('photos', 'PhotoController') to auto-generate full RESTful routes across locales—avoid repetitive boilerplate.->names(['en' => 'dashboard', 'fr' => 'tableau-bord']) for natural localization, not just translation.->except(['fr']) or ->only(['en', 'es']) to selectively expose routes by locale.->view('welcome') to map multilingual URIs to Blade views without controllers.->data([...]) or ->middleware([...]).route() with localized_route('home', [], 'fr') for explicit locale URLs, and current_route() to switch context (e.g., language switcher dropdowns).Request::localizedRouteIs('home') in Blade or middleware to check route context agnostic of locale prefix.multilingualResource, always include translated patterns like 'test/{test}' => 'teste/{test}'—missing entries cause broken parameterized URIs.prefix_default_locale to true to avoid inconsistent route naming (e.g., /en/about vs /about).DetectRequestLocale must run first in the web middleware group—placing it after auth/session causes locale detection to be too late.URL::signedLocalizedRoute() instead of route()—Laravel’s native signed routes won’t work with multilingual names.php artisan route:list to verify all generated localized routes—ensure the URI column matches expectations.MultilingualRouteServiceProvider customization or override Route::multilingual() resolution by listening to Route::afterResolving() in a custom macro.How can I help you explore Laravel packages today?