I am currently trying to use gettext with PHP and poedit. I wrote the following test.php file:
<?php
error_reporting(E_ALL | E_DEPRECATED | E_USER_DEPRECATED | -1);
bindtextdomain('messages', './i18n/');
textdomain('messages');
setlocale(LC_ALL, $_GET['l']);
putenv("LANG=".$_GET['l']);
echo _('test :-(');
?>
and this is my messages.po:
msgid ""
msgstr ""
"Project-Id-Version: Community Chess\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-10-07 18:34+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: Martin Thom <[email protected]>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-Basepath: /var/www/community-chess\n"
"X-Poedit-SearchPath-0: .\n"
#: test.php:8
msgid "test :-("
msgstr "Juhu :-)"
#~ msgid "test"
#~ msgstr "Juhu!"
My directory structure is
community-chess
test.php
i18n
de_DE
LC_MESSAGES
messages.po
messages.mo
As soon as I look at http://localhost/community-chess/test.php?l=de_DE I get "test :-("
I have generated the locale with
sudo locale-gen de_DE
and checked with
locale -a
Why doesn't it work? How can I get some feedback from gettext?
setlocale()
tryputenv("LANG=")
and the others. – marioZend_Translate
instead. It can deal with .mo/.po files – Pekka