shaunthegeek / laravel-locale-setter
detect Accept-Language, setLocale for Laravel
Installs: 60
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 1
pkg:composer/shaunthegeek/laravel-locale-setter
Requires
- laravel/framework: >=v11
Requires (Dev)
- laravel/pint: ^1.26
- orchestra/testbench: >=v9
- phpunit/phpunit: ^12.5
Replaces
README
Automatically scanning the lang directory for locales, detecting the HTTP Accept-Language header, and setting the Laravel locale — all are handled seamlessly by this package.
Installation
composer require shaunthegeek/laravel-locale-setter
Add Middleware
// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
$middleware->web(remove: [
\Illuminate\Routing\Middleware\SubstituteBindings::class,
]);
$middleware->web(append: [
ShaunTheGeek\LaravelLocaleSetter\Middleware\DetectLocale::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
]);
})
Optional
If you wish to modify the configuration, please publish it first.
php artisan vendor:publish --tag=locale-config