Apache gettext windows does not work/translate

Posted by Prashant Kandathil on Stack Overflow See other posts from Stack Overflow or by Prashant Kandathil
Published on 2012-07-22T06:46:42Z Indexed on 2012/12/18 17:03 UTC
Read the original article Hit count: 248

Filed under:
|
|
|

I am new to gettext.

Here is my setup: /Apache 2.2 PHP 5.3.6 Windows 7/

I have following code in the Apache/htdocs/test/index.php

<?php
    $language = 'de_DE'; 
    $translatefile = 'messages'; 
    setlocale(LC_ALL, $language);
    putenv("LANG=".$language); 
    bindtextdomain($translatefile, 'C:/locale'); 
    textdomain($translatefile); 

    echo gettext("Hello World!");
?>

I used PoEdit to generate the necessary translations under locale/de_DE/LC_MESSAGES/messsages.po & messages.mo The charset I used was UTF-8

When I visit http://localhost/test, the result is Hello World! when it should be Hall Welt!

As a test, I opened command prompt and navigated to the test folder. Then I typed in

php index.php 

The result that appeared in the console was

Hall Welt!

I am not sure why it is not working with Apache.

© Stack Overflow or respective owner

Related posts about php

Related posts about Windows