Revision [2121]

This is an old revision of MultiLanguageNumbers made by PhilDaintree on 2011-09-09 23:51:22.

 

The Problem

Some locales use different characters for the thousands separator and the decimal point. e.g. Europe tends to use a comma "," as a decimal point instead of the English full stop "." the French use a space rather than a comma for the thousands separator. e.g.

2,345.67

would be written

2 345,67

For people used to seeing and writing numbers in these alternative formats webERP is next to useless especially in the accounting area.

The Solution

In the includes/LanguageSetup.php script we have been using:

<%php
$Locale = setlocale (LC_NUMERIC, 'en_US');
%>
in order to display web-pages in the users locale with appropriate thousands separators and decimal points we must use either:
<%php
$Locale = setlocale (LC_NUMERIC, $_SESSION['Language']);
%>

OR

<%php
$Locale = setlocale (LC_ALL, $_SESSION['Language']);
%>

LC_ALL sets all settings for the locale to the user selected locale. However, it does not set LC_MESSAGES to the locale for some reason which I don't understand. I have settled on:

<%php
$Locale = setlocale (LC_ALL, $_SESSION['Language']);
$LocaleInfo = localeconv();
if (defined('LC_MESSAGES')){
$Locale = setlocale (LC_MESSAGES, $_SESSION['Language']);
}
%>

The reason the locale for LC_MESSAGES is only set when it is defined is that it returns a message on some systems that are not compiled with libintl (in particular Windows)
We used to only set the locale when the system was using the gettext for translations. However, now we are using the locale to display numbers correctly too so we need to set the locale correctly which ever method we are using to translate language strings.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki