PHP + gettext on Debian Woody 3.0 stable: Resolution

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

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

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

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

  echo _("Who are we");


2) Message file is ./locale/de_DE/LC_MESSAGES/ 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

4) Another trick: restart Apache

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


Site Timeline