Translating the text in a Laravel app is one problem, and allowing localized URLs is a different one. You want /dashboard in English and /es/panel in Spanish, both real routes that resolve, appear in route:list, and can be linked without knowing which language the visitor is on. Doing it by hand means a route group per language, duplicated definitions, and locale detection glued on top.
Laralang does that half. You declare a route once, list the languages, and it registers one real route per locale, names them, and keeps route() working. Here is the whole thing, including the parts that are easy to get wrong.
Install
composer require edulazaro/laralang
php artisan vendor:publish --tag="locales"
Publishing is not optional in practice. The config ships with a single locale, and both the middleware and the URL generator read the list from there, so until you fill it in your other languages are not recognised.
// config/locales.php
'locales' => ['en', 'es', 'fr'
Discussion
Leave the first comment
Be the first to leave a mark on this discussion.