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
This commit is contained in:
westi 2010-04-22 21:39:37 +00:00
parent e26aed0ac4
commit 9356c4b72d
4 changed files with 12 additions and 9 deletions

View File

@ -43,7 +43,8 @@ var userSettings = {
pagenow = '<?php echo $current_screen->id; ?>',
typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>',
adminpage = '<?php echo $admin_body_class; ?>',
thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>';
thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>';
//]]>
</script>
<?php

View File

@ -131,14 +131,13 @@ function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
* @since 2.3.0
*
* @param int $number The number to convert based on locale.
* @param int $decimals Precision of the number of decimal places. Deprectated.
* @param int $decimals Precision of the number of decimal places.
* @return string Converted number in string format.
*/
function number_format_i18n( $number, $decimals = null ) {
function number_format_i18n( $number, $decimals = 0 ) {
global $wp_locale;
$number = (int)$number;
if ( !is_null( $decimals ) ) _deprecated_argument( __FUNCTION__, '3.0' );
$formatted = number_format( $number, 0, null, $wp_locale->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;
}

View File

@ -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;

View File

@ -182,6 +182,10 @@ class WP_Locale {
$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 ) {
if ( isset($GLOBALS[$var]) )