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/
- I have my strings declared in my code like this:
_('test string');
- Then I ran
xgettest -L PHP test.php
, which generated mymessages.po
file. - I opened this file in poedit and translated my strings, then saved the file, which made a
messages.mo
file. - I took both the
.po
and.mo
files and moved them to[webroot]/locale/es/LC_MESSAGES/
(in this case, my translation was Spanish) 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 betweenen
andes
.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 toen
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?