Topic: LC_ALL locale issue fills up tmp/errors.log file
By default a Debian System has the locale as "C" and the output of locale bash command is:
# locale
LANG=C
LANGUAGE=
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=
This means that when testing for LC_ALL we will always get it as false in the includes/lang/gettext.php:
function set_language($lang_code, $encoding)
{
putenv("LANG=$lang_code");
putenv("LC_ALL=$lang_code");
putenv("LANGUAGE=$lang_code");
//$set = setlocale(LC_ALL, "$lang_code");
//$set = setlocale(LC_ALL, "$encoding");
// cover a couple of country/encoding variants
$up = strtoupper($encoding);
$low = strtolower($encoding);
$lshort = strtr($up, '-','');
$ushort = strtr($low, '-','');
if ($lang_code == 'C')
$set = setlocale(LC_ALL,'C');
else
$set = setlocale(LC_ALL, $lang_code.".".$encoding,
$lang_code.".".$up, $lang_code.".".$low,
$lang_code.".".$ushort, $lang_code.".".$lshort);
setlocale(LC_NUMERIC, 'C'); // important for numeric presentation etc.
if ($set === false)
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') // don't do this test if server is WIN
return 0;
$str = sprintf('language code "%s", encoding "%s" not supported by your system',
$lang_code, $encoding);
//$err = new GetText_Error($str);
//return PEAR::raise_error($err);
return raise_error("1 " . $str);
}
//return 0;
}
This raises the error in tmp/errors.log each time the FA scripts are executed:
[26-Sep-2014 00:44:58] 1 language code "en_US", encoding "iso-8859-1" not supported by your system
Commands tried to no avail:
locale
locale-gen
locale-gen en_US
dpkg-reconfigure locales
Contents of installed_languages.inc:
$installed_languages = array (
0 =>
array (
'code' => 'C',
'name' => 'English',
'encoding' => 'iso-8859-1',
),
1 =>
array (
'code' => 'en_US',
'name' => 'English US',
'encoding' => 'iso-8859-1',
'path' => 'lang/en_US',
),
);
$dflt_lang = 'C';
lang/en_US/LC_MESSAGES/en_US.mo exists.
Possible solution link:
http://www.gnu.org/software/libc/manual/html_node/Setting-the-Locale.html
where it is suggested to make it:
if ($lang_code == 'C')
$set = setlocale(LC_ALL,'');
else
..
..