From: SourceForge.net <no...@so...> - 2010-02-15 09:08:33
|
Bugs item #2951148, was opened at 2010-02-13 09:26 Message generated for change (Comment added) made by You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108956&aid=2951148&group_id=8956 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Admin Group: 2.1.3 Status: Open Resolution: None Priority: 5 Private: No Submitted By: mike () Assigned to: Franky Van Liedekerke (liedekef) Summary: esp_setlocale quietly fails to set up locale Initial Comment: System: Linux (Ubuntu, Hardy), PHP5, Apache2, gettext compiled in When the en_US.UTF-8 locale is not available on the host, setlocale() will quietly fail to change the locale. esp_setlocale($lang) will also quietly fail. (I presume this is true if ANY locale you attempt to use is not available on the host, when using the gettext native extension). One noticeable symptom is that test.php reports gettext is available and real but "%%%% Gettext Test Failed" is still displayed. I see messages on the mailing list about this issue. For the most part this is a minor issue; the failure will mostly be unnoticed as the failover language is English. However, poor suckers like me who try to modify the en_US localization file will be very confused. The output of test.php may also be confusing. The root cause of the problem can be resolved by installing the en_US.UTF-8 locale. In ubuntu, sudo locale-gen en_US.UTF-8 Note that "locale -a" will list existing locales. On the php_ESP side, when the locale is not set correctly, this should be detected and reported. For example, adding this code at the appropriate place in test.php will retrieve the current locale setting and ensure it was accurately set to language.charset. <li>LC_ALL: <?php check_string(setlocale(LC_ALL, 0), $ESPCONFIG['lang'].".".$ESPCONFIG['charset']); ?></li> Additional checks in esp_setlocale() may be called for; PHP docs say the return value of setlocale() when a locale is actually set varies from system to system, but also says it should return the locale if set properly. ---------------------------------------------------------------------- Comment By: mike () Date: 2010-02-15 09:08 Message: Certainly the user bears some responsibility, yet as always the hard working developer is stuck trying to make things more fool-proof. :) Note, however, that as far as I could tell I chose a locale that was available. The test.php page reports the locale as en_US, and I chose en_US, which IS installed on my server. I now know that the charset is set in phpESP.ini.php.default as UTF-8 but didn't realize this at the time (also my fault...). (Why no UTF-8? No idea. On my install of Ubuntu-server from Slicehost, the default charset was ISO-8859-15... certainly I bear responsibility for not noticing and someone should say something nasty to Slicehost.) In addition to adding a test to test.php, my only other thought was to set the default locale/charset to the current system default (via setlocale(LC_ALL, 0)) instead of using en_US.UTF-8 as the default (unless there is a problem getting the current locale or it is incompatible). This might be overkill and open a new world of problems. Certainly my problem is solved now, and hopefully future google searches will show the solution here. :) (For some reason, it didn't turn up the email list archives). ---------------------------------------------------------------------- Comment By: Franky Van Liedekerke (liedekef) Date: 2010-02-15 08:37 Message: Indeed many people on this list had this problem and always when I asked them "is the locale installed on your server" the person stopped responding. It is your own problem for selecting a locale not available, but indeed it should be made more fool-proof. I'll take a look at this! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108956&aid=2951148&group_id=8956 |