Localizing PHP applications: Error in HowTo

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
peter_b
Chatterbox
Posts: 383
Joined: Tue Nov 12, 2013 2:05 am

Localizing PHP applications: Error in HowTo

Post by peter_b »

[PROBLEM]
I've found a pretty good HowTo:
Localizing PHP Applications “The Right Way” (by Abdullah Abouzekry)

But the example in "Part 1" didn't work on my machine. The message id was displayed - but not the translation.
I checked everything several times, but couldn't find any errors. All files were where they should be, and I've double-checked for typos.

[SOLUTION]
In the end, the language string in the example (en_US) didn't match the installed locale on my system: "en_US.UTF-8".
So I changed the $language value to "en_US.UTF-8".

Additionally, I also set the environment variable "LANGUAGE" instead of "LANG", as in the example:

Code: Select all

putenv('LANGUAGE=' . $language);
Now it works! :D

Really nasty that "setlocale()" doesn't return more information when it fails to load the locale.
Post Reply