gettext: Messages not translated. No error message.

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

gettext: Messages not translated. No error message.

Post by ^rooker »

[PROBLEM]
Using gettext/poedit to make a PHP project translatable.
I have a working test-code from PHP and Javascript Internationalization using Gettext and Poedit (pontikis.net). When I move that working code to another machine, I suddenly don't get strings displayed translated, but also no error messages.

[SOLUTION]
The target locale was not installed on system.
Even if you provide the translation files, PHP will not switch to a locale which is not installed/configured on the system that your application is running.

In my case, PHP's setlocale() returned 'false' - indicating that I my target locale was missing.
Check if the locale is currently present and active:

Code: Select all

$ locale -a
If not, either uncomment them in "/etc/locale.gen" and then (re-)generate them:

Code: Select all

$ sudo locale-gen
Or rather do it the "Official Debian Way":

Code: Select all

$ sudo dpkg-reconfigure locales
There, make sure that all the languages/locales you're going to use are checked/selected. After pressing "Ok", they will automatically be (re-)generated.

This should do the trick :D
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply