shureban/laravel-localization
最新稳定版本:1.0.0
Composer 安装命令:
composer require shureban/laravel-localization
包简介
Laravel SDK for searching data in DB using requests
README 文档
README
Laravel middleware for automatically setting application locale based on HTTP "Accept-Language" header
Installation
Require this package with composer using the following command:
composer require shureban/laravel-localization
Add the following class to the providers array in config/app.php:
Shureban\LaravelLocalization\LocalizationServiceProvider::class,
You can also publish the config file to change implementations (i.e. interface to specific class).
php artisan vendor:publish --provider="Shureban\LaravelLocalization\LocalizationServiceProvider"
Usage
Register \Shureban\LaravelLocalization\Localization::class middleware in application's HTTP Kernel.
You can install it as global middleware in Kernel's $middleware property:
protected $middleware = [ ... \Shureban\LaravelLocalization\Localization::class ];
You can install it to specific middleware groups in Kernel's $middlewareGroups property:
protected $middlewareGroups = [ 'web' => [ ... \Shureban\LaravelLocalization\Localization::class ] ];
Or you can install is as route middleware in Kernel's $routeMiddleware and use it manually in routes:
Kernel:
protected $routeMiddleware = [ ... 'localization' => \Shureban\LaravelLocalization\Localization::class ];
Route file
Route::middleware(['localization'])->get('/', [AnyController::class, 'method']);
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 3.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-11