jDownloads Support Forum

Older Versions => jDownloads 3.2 (Support ended) => Suggestions - Feature Request => Topic started by: bositman on 06.12.2014 15:03:07

Title: Hundreds, thousands, millions separator in download hits - [Added in 3.2.25]
Post by: bositman on 06.12.2014 15:03:07
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 :)
Title: Re: Hundreds, thousands, millions separator in download hits
Post by: ColinM on 07.12.2014 17:23:06
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]
Title: Re: Hundreds, thousands, millions separator in download hits
Post by: bositman on 07.12.2014 18:57:11
Looks fine, that's exactly what I meant ;)
Title: Re: Hundreds, thousands, millions separator in download hits
Post by: bositman on 03.01.2015 22:28:29
Bump in case Arno forgot to implement :) Happy new year too!
Title: Re: Hundreds, thousands, millions separator in download hits
Post by: Arno on 04.01.2015 13:39:39
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.
Title: Re: Hundreds, thousands, millions separator in download hits
Post by: bositman on 04.01.2015 14:23:21
Hm making it locale aware is going to be harder...check here:

http://stackoverflow.com/questions/437371/php-locale-aware-number-format
Title: Re: Hundreds, thousands, millions separator in download hits
Post by: Arno on 05.01.2015 12:32:42
hm... thanks for the link.
Joomla has a function like getLocale(). Maybe can we use it.
Title: Re: Hundreds, thousands, millions separator in downloa6d hits
Post by: ColinM on 08.01.2015 01:41:24
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


Title: Re: Hundreds, thousands, millions separator in download hits
Post by: Arno on 23.01.2015 14:50:41
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]
Title: Re: Hundreds, thousands, millions separator in download hits - [Added in 3.2.25]
Post by: Arno on 23.01.2015 22:17:56
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.