PHP gettext issue: strings are only translated for English
<p>I'm using the php gettext implementation to get a website localized according to the user preferences (by analyzing the HTTP_ACCEPT_LANGUAGE).</p>

<p>I tested the translation system I built and it works correctly, but I just discovered (after I've added other languages) that when I try to use a different language it doesn't work, returning the untranslated string.</p>

<p>I get the right locale (debugging with German settings I get it's using de_DE), and I've the right .mo file (locale/de_DE/LC_MESSAGES/messages.mo).</p>

<p>I'm using this code to set up the translation environment:</p>

<pre><code>    putenv("LC_ALL=" . $g_locale);
    setlocale(LC_ALL,  $g_locale);
    bind_textdomain_codeset('messages', 'UTF-8');
    bindtextdomain('messages', './locale'); // echo here makes sure it's getting the right absolute path
    textdomain('messages');
</code></pre>

<p>Where $g_locale is "de_DE".</p>

<p>I tried following several solutions, I've installed the german locale and locale -a is telling de_DE.UTF-8 has been correctly installed. I've also restarted apache2.</p>

<p>But messages are still not translated for any language except en_US.</p>

<p>What could be the cause of this behaviour?
What can I do to make it work?</p>

<p>Thank you.</p>

<p>Edit: I forgot to say it's also working with the default system language (Italian).
It seems like a misconfiguration but I ran the right commands (sudo apt-get install language-pack-de-base).</p>
