<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — LC_ALL locale issue fills up tmp/errors.log file]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=5204&amp;type=atom" />
	<updated>2014-09-25T20:24:01Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=5204</id>
		<entry>
			<title type="html"><![CDATA[Re: LC_ALL locale issue fills up tmp/errors.log file]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=20983#p20983" />
			<content type="html"><![CDATA[<p>A reboot of the Debian machine now shows:<br /></p><div class="codebox"><pre><code># locale
LANG=
LANGUAGE=
LC_CTYPE=&quot;POSIX&quot;
LC_NUMERIC=&quot;POSIX&quot;
LC_TIME=&quot;POSIX&quot;
LC_COLLATE=&quot;POSIX&quot;
LC_MONETARY=&quot;POSIX&quot;
LC_MESSAGES=&quot;POSIX&quot;
LC_PAPER=&quot;POSIX&quot;
LC_NAME=&quot;POSIX&quot;
LC_ADDRESS=&quot;POSIX&quot;
LC_TELEPHONE=&quot;POSIX&quot;
LC_MEASUREMENT=&quot;POSIX&quot;
LC_IDENTIFICATION=&quot;POSIX&quot;
LC_ALL=</code></pre></div><p>And all works well!</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2014-09-25T20:24:01Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=20983#p20983</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[LC_ALL locale issue fills up tmp/errors.log file]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=20982#p20982" />
			<content type="html"><![CDATA[<p>By default a Debian System has the locale as &quot;C&quot; and the output of <strong>locale</strong> bash command is:<br /></p><div class="codebox"><pre><code># locale
LANG=C
LANGUAGE=
LC_CTYPE=&quot;C&quot;
LC_NUMERIC=&quot;C&quot;
LC_TIME=&quot;C&quot;
LC_COLLATE=&quot;C&quot;
LC_MONETARY=&quot;C&quot;
LC_MESSAGES=&quot;C&quot;
LC_PAPER=&quot;C&quot;
LC_NAME=&quot;C&quot;
LC_ADDRESS=&quot;C&quot;
LC_TELEPHONE=&quot;C&quot;
LC_MEASUREMENT=&quot;C&quot;
LC_IDENTIFICATION=&quot;C&quot;
LC_ALL=</code></pre></div><p>This means that when testing for LC_ALL we will always get it as false in the <strong>includes/lang/gettext.php</strong>:<br /></p><div class="codebox"><pre><code>    function set_language($lang_code, $encoding)
    {
        putenv(&quot;LANG=$lang_code&quot;);
        putenv(&quot;LC_ALL=$lang_code&quot;);
        putenv(&quot;LANGUAGE=$lang_code&quot;);

        //$set = setlocale(LC_ALL, &quot;$lang_code&quot;);
        //$set = setlocale(LC_ALL, &quot;$encoding&quot;);

        // cover a couple of country/encoding variants 
        $up = strtoupper($encoding);
        $low = strtolower($encoding);
        $lshort = strtr($up, &#039;-&#039;,&#039;&#039;);
        $ushort = strtr($low, &#039;-&#039;,&#039;&#039;);

        if ($lang_code == &#039;C&#039;)
            $set = setlocale(LC_ALL,&#039;C&#039;);
        else
            $set = setlocale(LC_ALL, $lang_code.&quot;.&quot;.$encoding, 
                $lang_code.&quot;.&quot;.$up, $lang_code.&quot;.&quot;.$low,
                $lang_code.&quot;.&quot;.$ushort,    $lang_code.&quot;.&quot;.$lshort);

        setlocale(LC_NUMERIC, &#039;C&#039;); // important for numeric presentation etc.
        if ($set === false) 
        {
            if (strtoupper(substr(PHP_OS, 0, 3)) === &#039;WIN&#039;) // don&#039;t do this test if server is WIN
                return 0;
            $str = sprintf(&#039;language code &quot;%s&quot;, encoding &quot;%s&quot; not supported by your system&#039;,
                $lang_code, $encoding);
            //$err = new GetText_Error($str);
            //return PEAR::raise_error($err);
            return raise_error(&quot;1 &quot; . $str);
        }
        //return 0;
    }</code></pre></div><p>This raises the error in <strong>tmp/errors.log</strong> each time the FA scripts are executed:<br /></p><div class="codebox"><pre><code>[26-Sep-2014 00:44:58] 1 language code &quot;en_US&quot;, encoding &quot;iso-8859-1&quot; not supported by your system</code></pre></div><p>Commands tried to no avail:<br />&nbsp; locale<br />&nbsp; locale-gen<br />&nbsp; locale-gen en_US<br />&nbsp; dpkg-reconfigure locales</p><p>Contents of <strong>installed_languages.inc</strong>:<br /></p><div class="codebox"><pre><code>$installed_languages = array (
  0 =&gt; 
  array (
    &#039;code&#039; =&gt; &#039;C&#039;,
    &#039;name&#039; =&gt; &#039;English&#039;,
    &#039;encoding&#039; =&gt; &#039;iso-8859-1&#039;,
  ),
  1 =&gt; 
  array (
    &#039;code&#039; =&gt; &#039;en_US&#039;,
    &#039;name&#039; =&gt; &#039;English US&#039;,
    &#039;encoding&#039; =&gt; &#039;iso-8859-1&#039;,
    &#039;path&#039; =&gt; &#039;lang/en_US&#039;,
  ),
);

$dflt_lang = &#039;C&#039;;</code></pre></div><p><strong>lang/en_US/LC_MESSAGES/en_US.mo</strong> exists.</p><p>Possible solution link:<br />http://www.gnu.org/software/libc/manual/html_node/Setting-the-Locale.html</p><p>where it is suggested to make it:<br /></p><div class="codebox"><pre><code>        if ($lang_code == &#039;C&#039;)
            $set = setlocale(LC_ALL,&#039;&#039;);
        else
..
..</code></pre></div>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2014-09-25T19:50:15Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=20982#p20982</id>
		</entry>
</feed>
