| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function handle($request, $next) |
||
| 19 | { |
||
| 20 | if (Session::has(NovaTranslation::localeSessionKey())) { |
||
| 21 | app()->setLocale( |
||
| 22 | Session::get(NovaTranslation::localeSessionKey()) |
||
| 23 | ); |
||
| 24 | } else { |
||
| 25 | $browserLocale = Locale::havingIso( |
||
| 26 | // Take first 2 (as described flags in config) |
||
| 27 | substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2) |
||
| 28 | ); |
||
| 29 | |||
| 30 | $locale = $browserLocale ? $browserLocale->iso : config('app.locale'); |
||
| 31 | Session::put(NovaTranslation::localeSessionKey(), $locale); |
||
| 32 | |||
| 33 | app()->setLocale($locale); |
||
| 34 | } |
||
| 35 | |||
| 36 | return $next($request); |
||
| 37 | } |
||
| 38 | } |
||
| 39 |