/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!$this->repository->isLocalized()) { return $next($request); } $locale = $this->getValidSessionLocale(); if (!$locale && $this->core->config('locale.request-based')) { $locale = $this->getRequestLocale($request); } if ($locale) { app()->setLocale($locale); } return $next($request); }
/** * Bind data to the view. * * @param View $view */ public function compose(View $view) { $view->with(['localized' => $this->repository->isLocalized(), 'currentLocale' => app()->getLocale(), 'availableLocales' => $this->repository->getAvailable()]); }