gettext: Messages not translated. No error message.
Posted: Tue Dec 06, 2016 6:09 pm
[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:
If not, either uncomment them in "/etc/locale.gen" and then (re-)generate them:
Or rather do it the "Official Debian Way":
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
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
Code: Select all
$ sudo locale-gen
Code: Select all
$ sudo dpkg-reconfigure locales
This should do the trick