Search code examples
phpapachelocalegettext

Translation to hebrew with PHP/Gettext fails


I've searched hours for a solution for this including in the documentation.

trying to use gettext for hebrew translations,

using PHP 5.3.1 and wamp,

it prints out "hello world" and not the Hebrew equivalent

$directory = '/locale';
$domain = 'messages';
$locale ="he_IL";

putenv("LANG=".$locale); //not needed for my tests, but people say it's useful for windows

setlocale( LC_ALL, $locale);
bindtextdomain($domain, $directory);
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');

echo _("hello world");

I use poedit to create the mo/po files, they are located on: ./locale/he_IL/LC_MESSAGES/messages.mo

the php file is at "./"

Why don't I get the hebrew text?


Solution

  • Ok solved,

    Had to update to PHP version 5.3.5/5.3.10

    and because I'm using windows I had to use this locale "Hebrew_Israel.1255" instead of "he_IL" (that's how windows calls the hebrew locale anyway).

    Of course I had to also rename the folders in the ./locale to "Hebrew_Israel.1255"

    Now the system successfully chooses the locale