Here's my ./locale/fr/LC_MESSAGES/messages.po
file:
msgid "NO GOOD"
msgstr "IT WORKED!"
Command used to generate the .mo file:
$ msgfmt -o locale/fr/LC_MESSAGES/messages.mo locale/fr/LC_MESSAGES/messages.po
My PHP file (being run via CLI, for testing purposes, as root).
<?php
bindtextdomain('messages','./locale');
textdomain('messages');
setlocale(LC_MESSAGES, 'fr');
echo gettext("NO GOOD");
Here's my output:
$ NO GOOD
PHPInfo:
GetText Support => enabled
Any ideas why this might not work?
Turns out the reason it wasn't working is the locale I choose has to be a recognized one by the system.
In my case, fr
is not a valid locale, I had to pick fr_FR.UTF-8
which the system recognizes...