WordPress.org

Make WordPress Core

Changeset 14190


Ignore:
Timestamp:
04/22/10 21:39:37 (5 years ago)
Author:
westi
Message:

Restore support for floating point numbers in number_format_i18n(). Fixes #10555.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-header.php

    r14184 r14190  
    4444    typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>', 
    4545    adminpage = '<?php echo $admin_body_class; ?>', 
    46     thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>'; 
     46    thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>', 
     47    decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>'; 
    4748//]]> 
    4849</script> 
  • trunk/wp-includes/functions.php

    r14184 r14190  
    132132 * 
    133133 * @param int $number The number to convert based on locale. 
    134  * @param int $decimals Precision of the number of decimal places. Deprectated. 
     134 * @param int $decimals Precision of the number of decimal places. 
    135135 * @return string Converted number in string format. 
    136136 */ 
    137 function number_format_i18n( $number, $decimals = null ) { 
     137function number_format_i18n( $number, $decimals = 0 ) { 
    138138    global $wp_locale; 
    139139    $number = (int)$number; 
    140     if ( !is_null( $decimals ) ) _deprecated_argument( __FUNCTION__, '3.0' ); 
    141     $formatted = number_format( $number, 0, null, $wp_locale->number_format['thousands_sep'] ); 
     140    $formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] ); 
    142141    return apply_filters( 'number_format_i18n', $formatted ); 
    143142} 
     
    164163 * @return bool|string False on failure. Number string on success. 
    165164 */ 
    166 function size_format( $bytes, $decimals = null ) { 
     165function size_format( $bytes, $decimals = 0 ) { 
    167166    $quant = array( 
    168167        // ========================= Origin ==== 
     
    173172        'B ' => 1,              // pow( 1024, 0) 
    174173    ); 
    175     if ( !is_null( $decimals ) ) _deprecated_argument( __FUNCTION__, '3.0' ); 
    176174    foreach ( $quant as $unit => $mag ) 
    177175        if ( doubleval($bytes) >= $mag ) 
    178             return number_format_i18n( round( $bytes / $mag ) ) . ' ' . $unit; 
     176            return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit; 
    179177 
    180178    return false; 
  • trunk/wp-includes/load.php

    r14184 r14190  
    220220    $timeend = $mtime[1] + $mtime[0]; 
    221221    $timetotal = $timeend - $timestart; 
    222     $r = number_format( $timetotal, $precision ); 
     222    $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); 
    223223    if ( $display ) 
    224224        echo $r; 
  • trunk/wp-includes/locale.php

    r14184 r14190  
    182182        $trans = __('number_format_thousands_sep'); 
    183183        $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans; 
     184         
     185        /* translators: $dec_point argument for http://php.net/number_format, default is . */ 
     186        $trans = __('number_format_decimal_point'); 
     187        $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans; 
    184188 
    185189        // Import global locale vars set during inclusion of $locale.php. 
Note: See TracChangeset for help on using the changeset viewer.