Re: gettext does not translate
| From: | Catalin Trifu | Date: | Sat, 11 Sep 2004 20:35:07 +0000 |
| Subject: | Re: gettext does not translate | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196416@lists.php.net to get a copy of this message | ||
Hi,
I had really bad headaches with gettext some time ago
and since then I decided to no longer use it. It's unreliable on
heavy loads (mixed english + translated texts), moving the scritps to
another machine means more headache, it relies on system calls which
are not "isolated", which means scritps can step on each others toes.
My advice is stay away of gettext. Try some DB framework for
translation; it definetely performs better and more reliable.
Or, if the site is small you can rely on included files.
Cheers,
catalin
"Christian David" <christian-david@web.de> wrote in message
news:20040911140749.38975.qmail@pb1.pair.com...
> 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!