Skip to content
Advertisement

Gettext not working, what’s wrong?

I’m using gettext for adding different translations into my webpage. I’ve just installed it and I think it works fine. I also use Poedit for the .po files.

This is the code I have for my gettext testing:

JavaScript

That code, returns me ‘gettext is supported’, but instead of showing me the translations, it shows me ‘HELLO WORLD’ and ‘TEST TRANSLATION’.

This is my messages.po file:

JavaScript

And it’s inside my ‘Locale/en_US/LC_MESSAGES’ folder, with also a messages.mo file successfully converted. (I’ve hidden the info of the file, the name, the project, etc.)

What am I doing wrong?
Thanks!

EDIT: I also might add that I use Ubuntu with PHP, Apache and all this things installed.

Advertisement

Answer

I’ve been having headaches with this one too. I added this and it worked:

putenv('LANGUAGE=en_US');

Next to that I use the following:

JavaScript

Also, in my setup it only started working when I added the iso code to the .po file:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement