title: Translation is not working with ZF2
body: <p>Thanks for your time trying to help me.</p>
  
  <p>I have been following this tutorial:</p>
  
  <p><a href="http://samminds.com/2012/09/zend-framework-2-translate-i18n-locale/" rel="nofollow">http://samminds.com/2012/09/zend-framework-2-translate-i18n-locale/</a></p>
  
  <p><a href="http://samminds.com/2012/09/create-po-language-files-using-poedit/" rel="nofollow">http://samminds.com/2012/09/create-po-language-files-using-poedit/</a></p>
  
  <p>and I think I have followed all steps but the translation mechanism is not working.</p>
  
  <p>INLT extension is installed and active on the system.</p>
  
  <p>At the module config I've added:</p>
  
  <pre><code>'translator' =&gt; array(
      'locale' =&gt; 'es_ES',
      'translation_file_patterns' =&gt; array(
          array(
              'type'     =&gt; 'gettext',
              'base_dir' =&gt; __DIR__ . '/../language',
              'pattern'  =&gt; '%s.mo',
              'text_domain' =&gt; __NAMESPACE__,
          ),
      ),
  ),
  </code></pre>
  
  <p>and inside the Module.php added the line to define the translation method.</p>
  
  <pre><code>public function onBootstrap(MvcEvent $e)
  {
      $translator = $e-&gt;getApplication()-&gt;getServiceManager()-&gt;get('translator');
      $translator
          -&gt;setLocale(\Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']))
          -&gt;setFallbackLocale('fr_FR');
  
      ...
      ...
  </code></pre>
  
  <p>I have created the po and mo file succefully and upload to the server at the right place.</p>
  
  <pre><code>vmamp@AMP30:/users/p0100/web/module/Application/language&gt; ls -l
  total 20
  -rw-r--r-- 1 vmamp users 2652 Jan 16 23:46 es_ES.mo
  -rw-r--r-- 1 vmamp users 4582 Jan 16 23:46 es_ES.po
  </code></pre>
  
  <p>for example this is a snipset of one the view where translation might occur:</p>
  
  <pre><code>            &lt;li class="moteur"&gt;&lt;?php echo $this-&gt;translate('Moteur')?&gt;&lt;/li&gt;
              &lt;li class="couleur"&gt;&lt;?php echo $this-&gt;translate('Couleur')?&gt;&lt;/li&gt;
              &lt;?php if (count($this-&gt;universeData['garnissage']) &gt; 1):?&gt;
              &lt;li class="selle"&gt;&lt;?php echo $this-&gt;translate('Selle')?&gt;&lt;/li&gt;
              &lt;?php endif;?&gt;
              &lt;?php if (count($this-&gt;universeData['jonc']) &gt; 1):?&gt;
              &lt;li class="jonc"&gt;&lt;?php echo $this-&gt;translate('Jonc')?&gt;&lt;/li&gt;
              &lt;?php endif;?&gt;
              &lt;?php if (count($this-&gt;universeData['retros']) &gt; 1):?&gt;
              &lt;li class="retros"&gt;&lt;?php echo $this-&gt;translate('Retros')?&gt;&lt;/li&gt;
              &lt;?php endif;?&gt;
              &lt;?php if (count($this-&gt;universeData['signature']) &gt; 1):?&gt;
              &lt;li class="signature"&gt;&lt;?php echo $this-&gt;translate('Signature')?&gt;&lt;/li&gt;
              &lt;?php endif;?&gt;
              &lt;li class="rangement"&gt;&lt;?php echo $this-&gt;translate('Rangement')?&gt;&lt;/li&gt;
              &lt;li class="confort"&gt;&lt;?php echo $this-&gt;translate('Confort')?&gt;&lt;/li&gt;
              &lt;li class="perso"&gt;&lt;?php echo $this-&gt;translate('Perso')?&gt;&lt;/li&gt;
  </code></pre>
  
  <p>and this is part of the content of the .po file (es_ES.po)</p>
  
  <pre><code>msgid "Couleur"
  msgstr "Color"
  
  #: view/application/application/configure.phtml:56
  msgid "Selle"
  msgstr "Asiento"
  
  #: view/application/application/configure.phtml:59
  msgid "Jonc"
  msgstr "Embellecedores"
  
  #: view/application/application/configure.phtml:62
  msgid "Retros"
  msgstr "Retrovisores"
  
  #: view/application/application/configure.phtml:65
  msgid "Signature"
  msgstr "Luminosidad"
  
  #: view/application/application/configure.phtml:67
  msgid "Rangement"
  msgstr "Orden"
  
  #: view/application/application/configure.phtml:68
  msgid "Confort"
  msgstr "Confort"
  </code></pre>
  
  <p>I'checked what $_SERVER['HTTP_ACCEPT_LANGUAGE'] returns and here is what it is:</p>
  
  <pre><code>es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
  </code></pre>
  
  <p>so I assume strings might be translated into Spanish but they don't. Since translation files were named as es_ES, and I see HTTP_ACCEPT_LANGUAGE returns a key as es-ES, I tried to renamed them to es-ES, but this has not solved the problem.</p>
  
  <p>Thinking on an encoding issue I've checked the charset of files and they are on utf8 as I set them on the correspondant metatag and what it is also the encoding I selected for the charset at poedit for charset and source charset. </p>
  
  <pre><code>vmamp@AMP30:/users/p0100/web/module/Application/language&gt; file -i es_ES.po
  es_ES.po: text/x-po charset=utf-8
  </code></pre>
  
  <p>Btw, when I display the file from the server side I appreciate charset mistakes (if I edit it from my place, for example with notepad+, special chars are right encoded). Why I am having this issue and how could I fix it?</p>
  
  <p>Anyway I have shown here strings those have not special chars and I suppose they might be well translated if I would implement the process right, but it seems I am missing something ...</p>
  
  <p>Anyone experienced with this field ?</p>
  
  <p>The application behavieur is like if the traslation mechanism was not added, there aren't any error.</p>
  
  <p>Thanks in advance for your time and effort.</p>
  
  <p>Best Regards.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I needed to add the Text Domain to the translations lines:</p>
  
  <pre><code>&lt;?php echo $this-&gt;translate('Moteur', 'Application')?&gt;
  </code></pre>
  
  <p>after adding it, the translation works fine.</p>