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....

Localizing PHP applications: Error in HowTo

Postby peter_b » Wed Nov 09, 2016 4:07 am

[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.
  • 0

User avatar
peter_b
Chatterbox
 
Posts: 308
Joined: Tue Nov 12, 2013 2:05 am
Reputation: 3

Return to Knowledge Base

Who is online

Users browsing this forum: Google [Bot] and 6 guests

Who is online over last 24 hours

Users browsed this forum in the last 24 hours: Google [Bot] and 33 guests

cron
Reputation System ©'