setLocale gives problems / #4047

Hi, I have to switch to new version of Streber due to upgrade server software on one of the Streber installations and I see, that there is other locale managing in Streber now.

I always obtain error:
WARNING: stdcommon.inc.php : 506 Could not set locale to 'pl_PL.utf8,pl_PL,plk'

I tried a lot of other combinations and... nothing helps.
So I tried to read info on setlocale on php.net and here are some more info from there:

from bruno dot cenou at revues dot org 20-Feb-2006 03:31

A little function to test available locales on a sytem :

<?php
function list_system_locales(){
   ob_start();
   system('locale -a');
   $str = ob_get_contents();
   ob_end_clean();
   return split("\n", trim($str));
}

$locale = "fr_FR.UTF8";
$locales = list_system_locales();

if(in_array($locale, $locales)){
       echo "yes yes yes....";
}else{
       echo "no no no.......";
}

?>


When executing this script on one of my web servers I always obtain result: no, no, no....

Another voice:

from pigmeu at pigmeu dot net 18-Oct-2004 10:42


!!WARNING!!

The "locale" always depend on the server configuration.

i.e.:
When trying to use "pt_BR" on some servers you will ALWAYS get false. Even with other languages.

The locale string need to be supported by the server. Sometimes there are diferents charsets for a language, like "pt_BR.utf-8" and "pt_BR.iso-8859-1", but there is no support for a _standard_ "pt_BR".

This problem occours in Windows platform too. Here you need to call "portuguese" or "spanish" or "german" or...

Maybe the only way to try to get success calling the function setlocale() is:
setlocale(LC_ALL, "pt_BR", "pt_BR.iso-8859-1", "pt_BR.utf-8", "portuguese", ...);

But NEVER trust on that when making functions like date conversions or number formating. The best way to make sure you are doing the right thing, is using the default "en_US" or "en_UK", by not calling the setlocale() function. Or, make sure that your server support the lang you want to use, with some tests.

Remember that: Using the default locale setings is the best way to "talk" with other applications, like dbs or rpc servers, too.

[]s

Pigmeu

I think, this method of setting locale is not good or just we should disable warning.
Read more comments on setlocale - some of the folks warns not to use setlocale at all....

Radek