tags:

views:

122

answers:

1

I can't seem to get gettext working, here.

I'm using MAMP Pro and phpinfo(); says that gettext is enabled.

I followed this tutorial: http://zez.org/article/articleview/42/1/

  1. I have my strings declared in my code like this: _('test string');
  2. Then I ran xgettest -L PHP test.php, which generated my messages.po file.
  3. I opened this file in poedit and translated my strings, then saved the file, which made a messages.mo file.
  4. I took both the .po and .mo files and moved them to [webroot]/locale/es/LC_MESSAGES/ (in this case, my translation was Spanish)
  5. In my code, I set the following:

    $lang = $_SESSION['lang']; // available to all views that include this file

    putenv('LC_ALL='.$lang);

    bindtextdomain('messages','./locale');

    textdomain('messages');

    ... where $_SESSION['lang'] I can easily toggle between en and es.

  6. I reload my page, then click on my link that toggles to es, but my strings are still showing up as the English versions and not the Spanish versions. Toggling back to en shows no change; it's always the English versions.

I get no error message anywhere so I'm a bit lost as to why I'm having this problem. Can anyone give me some guidance/help? Did I miss something?

A: 

It seems as though the problem may be with poedit. Originally, all my Spanish translations I had marked as "fuzzy". If I remove "fuzzy" from them, they show up on my webpage like they should.

I don't think this is normal behavoir, but hey, at least it works.

neezer