Skip to content

Commit

Permalink
Added laravel-localization packge
Browse files Browse the repository at this point in the history
  • Loading branch information
libern committed Jul 29, 2016
1 parent 4382294 commit 68a9745
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"cviebrock/image-validator": "2.0.*@beta",
"barryvdh/laravel-ide-helper": "^2.1",
"tymon/jwt-auth": "0.5.*",
"someline/rest-api-client": "^1.0"
"someline/rest-api-client": "^1.0",
"mcamara/laravel-localization": "1.1.*"
},
"require-dev": {
"phpunit/phpunit": "~4.0||~5.0",
Expand Down
30 changes: 30 additions & 0 deletions src/Someline/Support/Middleware/LocaleMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Someline\Support\Middleware;

use Closure;
use LaravelLocalization;
use Mcamara\LaravelLocalization\LanguageNegotiator;

class LocaleMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{

// get current locale
$locale = LaravelLocalization::getCurrentLocale();

// set locale
LaravelLocalization::setLocale($locale);

return $next($request);
}

}

0 comments on commit 68a9745

Please sign in to comment.