PHP + gettext on Debian Woody 3.0 stable: Resolution

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Pilka

    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_AL L, $language);
    echo "locale='$local e'";
    echo "<br>";
    echo "<br>";

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

    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
Working...