title: Making application locale aware (getting locale from URL)
body: <p>I need help getting the request locale code.</p>
  
  <p>My theory is to define the locale in the URL, as such:</p>
  
  <p>`<a href="http://localhost/en/services/web" rel="nofollow noreferrer">http://localhost/en/services/web</a></p>
  
  <p>for locale en (English)</p>
  
  <p>OR</p>
  
  <p>`<a href="http://localhost/fr/services/web" rel="nofollow noreferrer">http://localhost/fr/services/web</a></p>
  
  <p>for locale fr (French)</p>
  
  <p><code>and then extract the locale from the URL and have the routes still work
  </code></p>
  
  <p><strong>The value would replace <code>it</code> in the <code>$lang</code> variable</strong></p>
  
  <p>Here is my current code inside the <code>Application Module Class</code>:</p>
  
  <pre><code>public function onBootstrap(MvcEvent $e)
  {
    $lang = 'it'; // this needs to reflect current request locale instead
    $request = $e-&gt;getApplication()-&gt;getServiceManager()-&gt;get('Request');
    $translator = $e-&gt;getApplication()-&gt;getServiceManager()-&gt;get('MvcTranslator');
    $translator-&gt;addTranslationFile("phparray",Pluto::path('language',"$lang.php"));
    $viewHelperManager = $e-&gt;getApplication()-&gt;getServiceManager()-&gt;get('ViewHelperManager');
    $viewHelperManager-&gt;get('translate')-&gt;setTranslator($translator);
  }
  </code></pre>
  
  <p><code>My solution would be to have the variable $lang populated with the request locale</code> and the remaining url portion pertinent to routing</p>
  
  <p>I imagine theres going to be some modifications to my routing as well.</p>