calamandrei-lorenzo/laravel-browser-lang
Composer 安装命令:
composer require calamandrei-lorenzo/laravel-browser-lang
包简介
Auto detect browser language with middleware.
README 文档
README
Auto detect browser default language
This package make available a middleware that auto-detect the language accepted from the browser and set it as current locale.
Requirement
- PHP >= 7.4
- laravel/framework >= 5.8|6.0|7.0
Tested on laravel/framework >= 7.0
Installing
$ composer require calamandrei-lorenzo/laravel-browser-lang
Optional, you can publish the config file:
$ php artisan vendor:publish --provider="CalamandreiLorenzo\\LaravelBrowserLang\\ServiceProvider" --tag=config
Implement the middleware in your App\Http\Kernel:
use CalamandreiLorenzo\LaravelBrowserLang\Http\Middleware\BrowserLang; class Kernel extends HttpKernel { /** * The application's route middleware. * * These middleware may be assigned to groups or used individually. * * @var array */ protected $routeMiddleware = [ // ... 'detect-language' => BrowserLang::class ]; }
Usage
Route::middleware('detect-language')->group(static function () { // routes });
Otherwise set it as a global middleware in your App\Http\Kernel file.
class Kernel extends HttpKernel { /** * The application's global HTTP middleware stack. * * These middleware are run during every request to your application. * * @var array */ protected $middleware = [ // ... BrowserLang::class ]; }
Contributing
You can contribute in one of three ways:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
License
MIT
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-24