* Adding a new function to format numbers (commafy) and using it for formatNum
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Tue, 12 Apr 2005 23:21:59 +0000 (23:21 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Tue, 12 Apr 2005 23:21:59 +0000 (23:21 +0000)
  by default, this means that everyone that doesn't have a formatNum function
  will see the en_* format but those that do will continue to see what they
  already do.

languages/Language.php

index 341e479..0ca074b 100644 (file)
@@ -2390,9 +2390,19 @@ class Language {
         *        a floating point number. 
         */
        function formatNum( $number ) {
-               return $number;
+               return $this->commafy($number);
        }
-
+       
+       /**
+        * Adds commas to a given number
+        *
+        * @param mixed $_
+        * @return string
+        */
+       function commafy($_) {
+               return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
+       }
+               
        function listToText( $l ) {
                $s = '';
                $m = count($l) - 1;