uselocale/locale-laravel
A Laravel localization package for multilingual apps, with locale detection, language switching, localized routes, and a simple configurable API that integrates cleanly with Laravel middleware and views.
Require the package with Composer and confirm your app meets the release constraints:
composer require uselocale/locale-laravel:^2.0
2.0.1 adds Laravel 10.x compatibility, so verify laravel/framework and PHP versions before upgrading. If you are on Laravel 9 or 11, check the package’s composer.json constraints rather than assuming compatibility.
Publish any package config and language assets:
php artisan vendor:publish --provider="UseLocale\Locale\LocaleServiceProvider"
Check the README for the exact provider/tag names. Start by reviewing config/locale.php and the package README’s middleware/route examples.
Register the locale middleware if the package does not auto-register it. Typical placement is in the web middleware group, after session startup and before routes that depend on the current locale.
First use case: add a localized route group, resolve the current locale from the URL/session, and expose a simple language switcher. Keep Laravel’s normal __() / trans() calls as the translation API; the package should manage locale resolution and switching, not replace Laravel’s translator.
app()->setLocale() early in the request lifecycle. Keep custom resolution logic in a dedicated resolver or middleware rather than scattering App::setLocale() calls across controllers.app()->getLocale() in a small Blade component so views do not depend directly on package internals.hreflang links and canonicals from the same locale allowlist used by the middleware. This keeps routing, switcher, and SEO metadata consistent.php artisan config:clear and php artisan route:clear. Cached routes/config can make locale changes appear ignored.setLocale() or file paths.Accept-Language, default) in non-production environments. Most locale bugs are precedence bugs, not translation bugs.How can I help you explore Laravel packages today?