PHP gettext on Windows

I had the same problem, and wasted almost a day or so on it. Finally, I found a very simple solution, namely to uninstall WAMP Server (version 2.1), and install a newer version (WampServer 2.1e - 32 bits). It's strange, but it solved the problem completely.

Here is the sample code that worked for me:

<?php

    $locale = "deu_DEU";

    putenv("LC_ALL=$locale");
    setlocale(LC_ALL, $locale);

    bindtextdomain("greetings", "./locale");
    textdomain("greetings");

    echo _("Hello World");

?>

Hope it helps.


I ran into problems while working with gettext on my local machine, and after some search i found this page which solved my problem: http://www.kipras.com/blog/getting-gettext-to-work-in-apache-on-windows/96

I am quoting from the web page:

On Linux servers (or any other servers apart windows), the way to do it is this:

setlocale(LC_MESSAGES, “en_US”);

The correct way to set locality on windows is this:

putenv(“LC_ALL=en_US”);