title: Laravel app()->getLocale() inside routes always print the default "en"
body: <p>I encountred a problem when trying to prefixing my routes with new set locale.
  When I return app()->getLocale() from a controller or a route closure it returns new set locale correctly, but when I put it inside Route prefix I get the default one 'en'. In my case the new locale is 'ar'.</p>
  
  <p>This is my code inside web.php</p>
  
  <pre><code>&lt;?php
  
  
  //Request to put the choosen locale into the session
  Route::get('locale/{locale}', function($locale) {
  
      session()-&gt;put('userLocale', $locale);
      return redirect(app()-&gt;getLocale());
  });
  
  //Group of routes that are supposed to be prefixed with new set locale 'ar'
  Route::group(['prefix' =&gt; app()-&gt;getLocale(), 'middleware' =&gt; 'locale'], function() {
  
      Route::get('/', function() {
          return app()-&gt;getLocale();
      });
  });
  </code></pre>
  
  <p>And this is the middleware:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Middleware;
  
  use Closure;
  use Illuminate\Foundation\Application;
  use Illuminate\Http\Request;
  
  class Locale
  {
      protected $app;
  
      public function __construct(Application $app)
      {
          $this-&gt;app = $app;
      }
  
      /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Closure  $next
       * @return mixed
       */
      public function handle($request, Closure $next)
      {
          $this-&gt;app-&gt;setLocale(session('userLocale'));
          return $next($request);
      }
  }
  </code></pre>
  
  <p>Note the statement "app()->getLocale()" inside Route prefix, this statement's value always is "en". But when I return it from within the closure it prints the new set locale "ar".</p>
  
  <p>What I'm trying to say is that, <strong>inside prefix, app()->getLocale()'s value is always "en", but inside the Closure its value is "ar".</strong></p>
  
  <p>So when I run "localehost:8000/locale/ar" in the browser the output is "ar" and that is correct but the url becomes "localehost:8000/en" and that should be "localehost:8000/ar" isn'it ? When I run "localehost:8000/ar" in the browser I get a 404 page.</p>
  
  <p>I tried to set the prefix from within <strong>RouteServiceProvider's mapWebRoutes methode</strong> but It doesn't work because I think that the service provider is executed before the middlware so It can't recognize the new locale that is set by the middlware.</p>
  
  <p>I hope to get help <strong>or another approach to prefix the routes with new locale because maybe I'm doing somthing wrong.</strong></p>