mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Allow number_format to be internationalized. Props nbachiyski. fixes #3677
git-svn-id: http://svn.automattic.com/wordpress/trunk@5308 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
56add54053
commit
d3f52c3b45
@ -831,8 +831,8 @@ function _cat_row( $category, $level, $name_override = false ) {
|
||||
|
||||
$class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
|
||||
|
||||
$category->category_count = number_format( $category->category_count );
|
||||
$category->link_count = number_format( $category->link_count );
|
||||
$category->category_count = number_format_i18n( $category->category_count );
|
||||
$category->link_count = number_format_i18n( $category->link_count );
|
||||
$posts_count = ( $category->category_count > 0 ) ? "<a href='edit.php?cat=$category->cat_ID'>$category->category_count</a>" : $category->category_count;
|
||||
return "<tr id='cat-$category->cat_ID'$class>
|
||||
<th scope='row' style='text-align: center'>$category->cat_ID</th>
|
||||
|
@ -43,7 +43,7 @@ if ( $comments || $numcomments ) :
|
||||
<h3><?php _e('Comments'); ?> <a href="edit-comments.php" title="<?php _e('More comments...'); ?>">»</a></h3>
|
||||
|
||||
<?php if ( $numcomments ) : ?>
|
||||
<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format($numcomments) ); ?> »</a></strong></p>
|
||||
<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format_i18n($numcomments) ); ?> »</a></strong></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<ul>
|
||||
@ -103,9 +103,9 @@ $numposts = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_t
|
||||
$numcomms = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
|
||||
$numcats = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories");
|
||||
|
||||
$post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format($numposts), 'edit.php');
|
||||
$comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format($numcomms), 'edit-comments.php');
|
||||
$cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format($numcats), 'categories.php');
|
||||
$post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format_i18n($numposts), 'edit.php');
|
||||
$comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format_i18n($numcomms), 'edit-comments.php');
|
||||
$cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format_i18n($numcats), 'categories.php');
|
||||
?>
|
||||
|
||||
<p><?php printf(__('There are currently %1$s and %2$s, contained within %3$s.'), $post_str, $comm_str, $cat_str); ?></p>
|
||||
|
@ -83,6 +83,14 @@ function date_i18n($dateformatstring, $unixtimestamp) {
|
||||
return $j;
|
||||
}
|
||||
|
||||
function number_format_i18n($number, $decimals = null) {
|
||||
global $wp_locale;
|
||||
// let the user override the precision only
|
||||
$decimals = is_null($decimals)? $wp_locale->number_format['decimals'] : intval($decimals);
|
||||
|
||||
return number_format($number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']);
|
||||
}
|
||||
|
||||
function get_weekstartend($mysqlstring, $start_of_week) {
|
||||
$my = substr($mysqlstring,0,4);
|
||||
$mm = substr($mysqlstring,8,2);
|
||||
|
@ -87,6 +87,18 @@ class WP_Locale {
|
||||
$this->meridiem['AM'] = __('AM');
|
||||
$this->meridiem['PM'] = __('PM');
|
||||
|
||||
// Numbers formatting
|
||||
// See http://php.net/number_format
|
||||
|
||||
$trans = __('number_format_decimals');
|
||||
$this->number_format['decimals'] = ('number_format_decimals' == $trans) ? 0 : $trans;
|
||||
|
||||
$trans = __('number_format_decimal_point');
|
||||
$this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
|
||||
|
||||
$trans = __('number_format_thousands_sep');
|
||||
$this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
|
||||
|
||||
// Import global locale vars set during inclusion of $locale.php.
|
||||
foreach ( $this->locale_vars as $var ) {
|
||||
if ( isset($GLOBALS[$var]) )
|
||||
@ -138,4 +150,4 @@ class WP_Locale {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -69,7 +69,7 @@ function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(
|
||||
$mtime = $mtime[1] + $mtime[0];
|
||||
$timeend = $mtime;
|
||||
$timetotal = $timeend-$timestart;
|
||||
$r = number_format($timetotal, $precision);
|
||||
$r = number_format_i18n($timetotal, $precision);
|
||||
if ( $display )
|
||||
echo $r;
|
||||
return $r;
|
||||
|
Loading…
Reference in New Issue
Block a user