470,815 Members | 1,103 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

PHP + gettext on Debian Woody 3.0 stable: Resolution

After several hours I found out how to make this work:

1) Here is the test.php script, "Who are we" is the message for the
translation

<?
$language = "de_DE";
putenv("LC_ALL=$language");
$locale = setlocale(LC_ALL, $language);
echo "locale='$locale'";
echo "<br>";
echo "<br>";

$domain = "messages";
bindtextdomain($domain, "./locale");
textdomain($domain);

echo _("Who are we");

die;
?>

2) Message file is ./locale/de_DE/LC_MESSAGES/messages.mo in my case

3) Here is the trick: de_DE locales must be generated by Debian
administrator (root), otherwise setlocale() function returns ""
(failure) instead of "de_DE" !

One of the ways how to do that is "dpkg-reconfigure locales". Check
"de_DE ISO-8859-1" option, it will generate /usr/lib/locale/de_DE for
you.

4) Another trick: restart Apache

5) Now it should work; test.php prints "Who are we in GERMAN" string
for me

Martin
Jul 17 '05 #1
0 1353

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Rene Pijlman | last post: by
2 posts views Thread by Herbert Straub | last post: by
3 posts views Thread by Martijn van Oosterhout | last post: by
7 posts views Thread by Oliver Elphick | last post: by
1 post views Thread by Erwin Brandstetter | last post: by
4 posts views Thread by Brian van den Broek | last post: by
6 posts views Thread by BartlebyScrivener | last post: by
2 posts views Thread by paolob | last post: by
8 posts views Thread by howa | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.