I am trying to use gettext to support localization on my site. I followed various gettext configuration guides and did the following:
I created the following files and directories in the root directory of my project:
test.php locale/ de_DE LC_MESSAGES messages.mo messages.po en_GB LC_MESSAGES messages.mo messages.po
I used Poedit to create the above .po and mo files. I sued the use of Unix line endings, UTF-8 and set the language and country accordingly.
Then I created a PHP script called test.php that has the following code:
<?php define('LOCALE', 'de_DE'); // Set up environmental variables putenv("LC_ALL=" . LOCALE); setlocale(LC_ALL, LOCALE); bindtextdomain("messages", "./locale"); bind_textdomain_codeset("messages", LOCALE .".utf8"); textdomain("messages"); die(gettext('This is a test.')); ?>
I imported the text "This is a test." to Poedit and provided the translation and saved it.
But for some reason, the test.php script only outputs the source code, untranslated. He refuses to download the version for translation files.
It is worth noting that the server runs Linux (Ubuntu), Apache 2.2.11 and PHP 5.2.6-3ubuntu4.5. I checked phpinfo() and gettext is enabled.
Can someone help me? Thanks.
php apache localization gettext
Camsoft
source share