Search code examples
phpgettext

How can I use Gettext in PHP?


I did this so far

$locale = 'fr_FR';
$domain = 'bla';
$path = 'C:\wamp\www\site/lang';

putenv("LC_ALL={$locale}");
setlocale(LC_ALL, $locale);
bindtextdomain($domain, $path);
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');

(bintextdomain returns C:\wamp\www\site\lang)

But I don't get my messages translated.

Using echo dcgettext('bla', $english_message, 1); and I get the original message shown, not the translation.

What is the "category" argument for? I just passed 1 because I don't know what is supposed to represent...


Solution

  • $locale = 'fra';
    

    fr_FR is for unix, more info on http://msdn.microsoft.com/en-us/library/39cwe7zf%28vs.71%29.aspx