From 9356c4b72df6e2b1af83d66fee0628a701278f56 Mon Sep 17 00:00:00 2001 From: westi Date: Thu, 22 Apr 2010 21:39:37 +0000 Subject: [PATCH] Restore support for floating point numbers in number_format_i18n(). Fixes #10555. git-svn-id: http://svn.automattic.com/wordpress/trunk@14190 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-header.php | 3 ++- wp-includes/functions.php | 12 +++++------- wp-includes/load.php | 2 +- wp-includes/locale.php | 4 ++++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 8f20238303..95951ed29c 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -43,7 +43,8 @@ var userSettings = { pagenow = 'id; ?>', typenow = 'post_type) ) echo $current_screen->post_type; ?>', adminpage = '', - thousandsSeparator = 'number_format['thousands_sep'] ); ?>'; + thousandsSeparator = 'number_format['thousands_sep'] ); ?>', + decimalPoint = 'number_format['decimal_point'] ); ?>'; //]]> number_format['thousands_sep'] ); + $formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] ); return apply_filters( 'number_format_i18n', $formatted ); } @@ -163,7 +162,7 @@ function number_format_i18n( $number, $decimals = null ) { * @param int $decimals Precision of number of decimal places. Deprecated. * @return bool|string False on failure. Number string on success. */ -function size_format( $bytes, $decimals = null ) { +function size_format( $bytes, $decimals = 0 ) { $quant = array( // ========================= Origin ==== 'TB' => 1099511627776, // pow( 1024, 4) @@ -172,10 +171,9 @@ function size_format( $bytes, $decimals = null ) { 'kB' => 1024, // pow( 1024, 1) 'B ' => 1, // pow( 1024, 0) ); - if ( !is_null( $decimals ) ) _deprecated_argument( __FUNCTION__, '3.0' ); foreach ( $quant as $unit => $mag ) if ( doubleval($bytes) >= $mag ) - return number_format_i18n( round( $bytes / $mag ) ) . ' ' . $unit; + return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit; return false; } diff --git a/wp-includes/load.php b/wp-includes/load.php index b765a896ef..e46b9de60e 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -219,7 +219,7 @@ function timer_stop( $display = 0, $precision = 3 ) { // if called like timer_st $mtime = explode( ' ', $mtime ); $timeend = $mtime[1] + $mtime[0]; $timetotal = $timeend - $timestart; - $r = number_format( $timetotal, $precision ); + $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); if ( $display ) echo $r; return $r; diff --git a/wp-includes/locale.php b/wp-includes/locale.php index 882e9395db..4972b8b7dc 100644 --- a/wp-includes/locale.php +++ b/wp-includes/locale.php @@ -181,6 +181,10 @@ class WP_Locale { /* translators: $thousands_sep argument for http://php.net/number_format, default is , */ $trans = __('number_format_thousands_sep'); $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans; + + /* translators: $dec_point argument for http://php.net/number_format, default is . */ + $trans = __('number_format_decimal_point'); + $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans; // Import global locale vars set during inclusion of $locale.php. foreach ( (array) $this->locale_vars as $var ) {