Index: trunk/phase3/languages/Language.php |
— | — | @@ -2612,12 +2612,11 @@ |
2613 | 2613 | */ |
2614 | 2614 | function commafy( $_ ) { |
2615 | 2615 | $digitGroupingPattern = $this->digitGroupingPattern(); |
2616 | | - |
| 2616 | + |
2617 | 2617 | if ( !$digitGroupingPattern || $digitGroupingPattern === "###,###,###" ) { |
2618 | 2618 | //default grouping is at thousands, use the same for ###,###,### pattern too. |
2619 | 2619 | return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); |
2620 | | - } |
2621 | | - else { |
| 2620 | + } else { |
2622 | 2621 | // Ref: http://cldr.unicode.org/translation/number-patterns |
2623 | 2622 | $numberpart = array(); |
2624 | 2623 | $decimalpart = array(); |
— | — | @@ -2625,28 +2624,27 @@ |
2626 | 2625 | preg_match( "/\d+/", $_, $numberpart ); |
2627 | 2626 | preg_match( "/\.\d*/", $_, $decimalpart ); |
2628 | 2627 | $groupedNumber = ( count( $decimalpart ) > 0 ) ? $decimalpart[0]:""; |
2629 | | - if ( $groupedNumber === $_){ |
2630 | | - //the string does not have any number part. Eg: .12345 |
2631 | | - return $groupedNumber; |
| 2628 | + if ( $groupedNumber === $_ ){ |
| 2629 | + //the string does not have any number part. Eg: .12345 |
| 2630 | + return $groupedNumber; |
2632 | 2631 | } |
2633 | 2632 | $start = $end = strlen( $numberpart[0] ); |
2634 | | - while ( $start > 0 ) |
2635 | | - { |
2636 | | - $match = $matches[0][$numMatches -1] ; |
2637 | | - $matchLen = strlen( $match ); |
2638 | | - $start = $end - $matchLen; |
2639 | | - if ( $start < 0 ) { |
2640 | | - $start = 0; |
2641 | | - } |
2642 | | - $groupedNumber = substr( $_ , $start, $end -$start ) . $groupedNumber ; |
2643 | | - $end = $start; |
2644 | | - if ( $numMatches > 1 ) { |
2645 | | - // use the last pattern for the rest of the number |
2646 | | - $numMatches--; |
2647 | | - } |
2648 | | - if ( $start > 0 ) { |
2649 | | - $groupedNumber = "," . $groupedNumber; |
2650 | | - } |
| 2633 | + while ( $start > 0 ) { |
| 2634 | + $match = $matches[0][$numMatches -1] ; |
| 2635 | + $matchLen = strlen( $match ); |
| 2636 | + $start = $end - $matchLen; |
| 2637 | + if ( $start < 0 ) { |
| 2638 | + $start = 0; |
| 2639 | + } |
| 2640 | + $groupedNumber = substr( $_ , $start, $end -$start ) . $groupedNumber ; |
| 2641 | + $end = $start; |
| 2642 | + if ( $numMatches > 1 ) { |
| 2643 | + // use the last pattern for the rest of the number |
| 2644 | + $numMatches--; |
| 2645 | + } |
| 2646 | + if ( $start > 0 ) { |
| 2647 | + $groupedNumber = "," . $groupedNumber; |
| 2648 | + } |
2651 | 2649 | } |
2652 | 2650 | return $groupedNumber; |
2653 | 2651 | } |