News:

Dear forum visitors, if the support forum is not available, please try again a few minutes later. Thanks!

Main Menu
Support-Forum

Hundreds, thousands, millions separator in download hits - [Added in 3.2.25]

Started by bositman, 06.12.2014 15:03:07

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bositman

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 :)
  •  

ColinM

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]
Colin M
  •  

bositman

  •  

bositman

Bump in case Arno forgot to implement :) Happy new year too!
  •  

Arno

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.
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

bositman

  •  

Arno

hm... thanks for the link.
Joomla has a function like getLocale(). Maybe can we use it.
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

ColinM

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


Colin M
  •  

Arno

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]
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

Arno

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.
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •