title: Laravel change language depending on a $_GET parameter
body: <p>A simple scenario when we want to setup the Locale Language settings (App::setLocale()) depending on a $_GET parameter as in following URL:</p>
  
  <p><a href="http://aboutlaravel.com/?language_code=en" rel="nofollow noreferrer">http://aboutlaravel.com/?language_code=en</a> </p>
  
  <p><strong>Possible Solution:</strong> Create a middleware and register it in app/Http/Kernel.php</p>
  
  <pre><code>protected $middlewareGroups = [
      'web' =&gt; [
          ...
          \App\Http\Middleware\Localization::class
      ],
  </code></pre>
  
  <p>The Localization middleware will look like this:</p>
  
  <pre><code>public function handle($request, Closure $next)
  {
      if(isset($_GET['language_code'])) {
          if ($_GET['language_code'] == "en") {
              App::setLocale("en");
          } else if ($_GET['language_code'] == "de") {
              App::setLocale("de");
          }
      }
      return $next($request);
  }
  </code></pre>