Pretty simple really, for jdownload users who have downloads with A LOT of hits, we end up with a huge number with no separator, which makes it very hard to discern if it's thousands or millions and in general see what kind of number it is.
It seems there already is a php function to do this, although it's php4 and 5..maybe there is a function for older versions too (not sure what is the minimum php version for jdownloads 3.x at this time..)
http://php.net/manual/en/function.number-format.php
Thanks :)
Presumably something like the attached pic would do? ;D Hope this is OK for the French! ???
Will send code change to Arno.
[gelöscht durch Administrator]
Looks fine, that's exactly what I meant ;)
Bump in case Arno forgot to implement :) Happy new year too!
Happy new year...
Maybe i have forget this suggestion.
Colin? Can you send me again the code snippet? :-\
But it must be okay for all users, not only for french, german or english users.
Not sure that number_format() use locale settings.
Hm making it locale aware is going to be harder...check here:
http://stackoverflow.com/questions/437371/php-locale-aware-number-format
hm... thanks for the link.
Joomla has a function like getLocale(). Maybe can we use it.
Arno
Think following function will work. It came from
http://us3.php.net/manual/en/function.number-format.php#76448
?php
function strtonumber( $str, $dec_point=null, $thousands_sep=null )
{
if( is_null($dec_point) || is_null($thousands_sep) ) {
$locale = localeconv();
if( is_null($dec_point) ) {
$dec_point = $locale['decimal_point'];
}
if( is_null($thousands_sep) ) {
$thousands_sep = $locale['thousands_sep'];
}
}
$number = (float) str_replace($dec_point, '.', str_replace($thousands_sep, '', $str));
if( $number == (int) $number ) {
return (int) $number;
} else {
return $number;
}
}
In java I found this reference
http://developer.android.com/reference/java/text/NumberFormat.html
Hi Colin,
when i try local this code snippet i get not correct results. Allways the same wrong values. :-\
Maybe a problem with xampp. I will check the joomla getLocale()...
[gelöscht durch Administrator]
I have now solved this.
The reuired separators are always stored in the main Joomla language files:
Quote
; Localized number format
DECIMALS_SEPARATOR="."
THOUSANDS_SEPARATOR=","
So we have now with version 3.2.25 also correct formatted values for every language.