views:

69

answers:

2

I'm trying to load my .mo translations using the following code, but it doesn't work. I have the php gettext ext. enabled in my phpinfo() and all the required locales are installed. Did I miss anything?

$locale = "en_US";

putenv("LC_ALL=$locale");

setlocale(LC_ALL, $locale);

bindtextdomain("messages", "./locale");
textdomain("messages");

My .mo file is located in ./locale/en_US/messages.mo

+2  A: 

When an apache thread loads an .mo file, it will not reload it until the apache thread is recycled. So if you update the .mo file, and want to be sure that your php is using that new .mo file, you actually need to either restart apache or use a different name for the mo file.

Anyway, I would set the LANG environment variable.

Lars D
Is that what you mean?:$language = 'en US.UTF-8';putenv("LANG=$language");I have tried to reload apache with sudo /etc/init.d/apache2 reload but It didn't solve it.
mnml
@mnml: not reload, but restart apache, i.e. sudo /etc/init.d/apache2 restart
Residuum
@Residuum: I just tried that and It's still not doing it.
mnml
A: 

You probably need to change the path so that it is absolute, instead of relative.

Lars D