Conditions | 8 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
10 | public function handle(Request $request, Closure $next) |
||
11 | { |
||
12 | if (!extension_loaded('intl') || app()->getLocale() != '') { |
||
|
|||
13 | return $next($request); |
||
14 | } |
||
15 | |||
16 | $headerValue = $request->server('HTTP_ACCEPT_LANGUAGE'); |
||
17 | if ($headerValue !== null && !is_array($headerValue) && $headerValue !== "") { |
||
18 | $locale = \Locale::acceptFromHttp($headerValue); |
||
19 | |||
20 | if ($locale !== false && $locale !== "") { |
||
21 | $locale = substr($locale, 0, 2); |
||
22 | app()->setLocale($locale); |
||
23 | } |
||
24 | } |
||
25 | |||
26 | |||
27 | return $next($request); |
||
28 | } |
||
30 |