I've been struggling with Gettext now for ages and just can't get it to work. I would be forever grateful if someone could help me with this... I have looked for solutions and tried several variants but nothing is working for me.
I have created the following file structure:
/var/www/battlestox/battlestox.com/sites/battlestox/www/locale/de_DE/LC_MESSAGE/messages.po /var/www/battlestox/battlestox.com/sites/battlestox/www/locale/de_DE/LC_MESSAGE/messages.mo
the data in the .po file is simply:
msgid ""
msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "qwerty"
msgstr "The Translator works!"
The php file hase the following code:
putenv("LANG=de_DE.UTF-8");
setlocale(LC_MESSAGES, 'de_DE.UTF-8');
bindtextdomain('messages', 'locale');
bind_textdomain_codeset('messages', 'UTF-8');
textdomain('messages');
echo gettext("qwerty");
echo _("qwerty");
output: qwertyqwerty - so no translation happening. when I echo bindtextdomain('messages', 'locale'); I get:
/var/www/battlestox/battlestox.com/sites/battlestox/www/locale
so I believe it's pointing to the correct location..
I have checked that gettext is installed in php and locales on the server are available..
:locale -a
de_DE
de_DE.iso88591
de_DE.iso885915@euro
de_DE.utf8
de_DE@euro
I'm running PHP 5.2, Apache 2.2.3, CentOS
Please be gentle, I am very basic on linux..
Thanks for any help!
I think that your .mo directory should be /var/www/..blah../locale/de_DE/LC_MESSAGES That's LC_MESSAGES, plural.
Also as John says, your locale name doesn't look quite right.
If you change the .mo file you need to restart apache. Have you done this?