Laravel middleware for setting application locale based on HTTP Accept-Language header
Laravel middleware for automatically setting application locale based on HTTP "Accept-Language" header
- PHP 8.0 or higher.
- Laravel ^8.0, ^9.0 or higher
You can install the package via composer:
composer require orkhanahmadov/laravel-accept-language-middleware
\Orkhanahmadov\LaravelAcceptLanguageMiddleware\Middleware::class middleware in application's HTTP Kernel.
You can install it as global middleware in Kernel's
protected $middleware = [ ... \Orkhanahmadov\LaravelAcceptLanguageMiddleware\Middleware::class ];
You can install it to specific middleware groups in Kernel's
protected $middlewareGroups = [ 'web' => [ ... \Orkhanahmadov\LaravelAcceptLanguageMiddleware\Middleware::class ] ];
Or you can install is as route middleware in Kernel's
$routeMiddleware and use it manually in routes:
protected $routeMiddleware = [ ... 'accept-language' => \Orkhanahmadov\LaravelAcceptLanguageMiddleware\Middleware::class ];
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email firstname.lastname@example.org instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.