gettext does not translate
| From: | Christian David | Date: | Sat, 11 Sep 2004 14:08:00 +0000 |
| Subject: | gettext does not translate | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-196396@lists.php.net to get a copy of this message | ||
Hello!
I wrote this skript, but gettext returns only the english string.
I could not find a bug at bugs.php.net, so I think I forgot something.
I have Debian Linux, PHP Version 4.3.4 and Gettext 0.14.1 (PHP and Gettext
as debian pakages)
gettext.php in /var/www/gymbay/
<?php
// Set language to German
setlocale(LC_ALL, 'de_DE');
// Specify location of translation tables
bindtextdomain("messages", "i18n");
// Choose domain
textdomain("messages");
// Translation is (should) looking for in
i18n/de_DE/LC_MESSAGES/messages.mo now
// Print a test message
echo gettext("Welcome to My PHP Application");
// Or use the alias _() for gettext()
echo _("Have a nice day");
// Output:
// Welcome to My PHP ApplicationHave a nice day
?>
messages.po
# translation of messages.po to german
# This file is distributed under the same license as the PACKAGE package.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER.
# Christian Dávid <christian-david@web.de>, 2004.
#
msgid ""
msgstr ""
"Project-Id-Version: messages\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2004-09-11 15:50+0200\n"
"PO-Revision-Date: 2004-09-11 15:52+0200\n"
"Last-Translator: Christian Dávid <christian-david@web.de>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.3.1\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: gettext.php:15
msgid "Welcome to My PHP Application"
msgstr "Willkommen zu meiner PHP Anwendung"
#: gettext.php:18
msgid "Have a nice day"
msgstr "Wir wünschen Ihnen einen schönen Tag"
and the "messages.mo" is in /var/www/gymbay/i18n/de_DE/LC_MESSAGES/
Thank you!