Page 1 of 1

Localizing PHP applications: Error in HowTo

Posted: Wed Nov 09, 2016 4:07 am
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.