public function __construct(Manager $manager)
 {
     $this->manager = $manager;
     $userlang = Auth::user()->lang;
     if (!$userlang == "") {
         App::setlocale($userlang);
     }
 }
Ejemplo n.º 2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $prefix = $request->lng;
     $lang = Languages::lists('id', 'prefix');
     if (!empty($lang[$prefix])) {
         self::$lng_id = $lang[$prefix];
         //global $lang_id = self::$lng_id;
         App::setlocale($prefix);
     } else {
         //global $lang_id = self::$lng_id;
     }
     return $next($request);
 }
Ejemplo n.º 3
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $locale = $this->getLocaleFromDomainName();
     if (!$locale) {
         $locale = config('app.locale');
         $firstSegment = $request->segment(1);
         if (in_array($firstSegment, config('translatable.locales'))) {
             $locale = $firstSegment;
         }
     }
     App::setlocale($locale);
     // Not very reliable, need to be refactored
     $localeAndCountry = $locale . '_' . strtoupper($locale);
     setlocale(LC_ALL, $localeAndCountry . '.utf8', $localeAndCountry . '.utf-8', $localeAndCountry);
     // Throw a 404 if website in this language is offline
     if (!config('typicms.' . $locale . '.status')) {
         abort(404);
     }
     // Remove preview param if no admin user connected
     if ($request->input('preview') && !Auth::check()) {
         return Redirect::to($request->path());
     }
     return $next($request);
 }