public function handle($request, Closure $next) { if (Session::has('applocale') and array_key_exists(Session::get('applocale'), Config::get('languages'))) { App::setLocale(Session::get('applocale')); setlocale(LC_TIME, Session::get('applocale')); Carbon::setLocale(\Locale::getPrimaryLanguage(Session::get('applocale'))); } else { App::setLocale(Config::get('app.fallback_locale')); setlocale(LC_TIME, Config::get('app.fallback_locale')); Carbon::setLocale(\Locale::getPrimaryLanguage(Config::get('app.fallback_locale'))); } return $next($request); }
public function handle($request, Closure $next) { $sessionAppLocale = session()->get('applocale'); if (session()->has('applocale') and array_key_exists($sessionAppLocale, Config::get('languages'))) { app()->setLocale($sessionAppLocale); setlocale(LC_TIME, $sessionAppLocale); Carbon::setLocale(\Locale::getPrimaryLanguage($sessionAppLocale)); return $next($request); } $fallbackLocale = Config::get('app.fallback_locale'); app()->setLocale($fallbackLocale); setlocale(LC_TIME, $fallbackLocale); Carbon::setLocale(\Locale::getPrimaryLanguage($fallbackLocale)); return $next($request); }