private function setLocale($locale, $request)
    {
        $allowedLangs = array_keys(Localizer::allowedLanguages());
        if (config('localizer.block_unallowed_langs') && !in_array($locale, $allowedLangs)) {
            abort(404, 'Unallowed language');
        }

        if (Auth::check()) {
            $user = Auth::User();
            $user->locale = $locale;
            $user->save();
        } else {
            $request->session()->put('locale', $locale);
        }
    }