Make WordPress Core

Changeset 5308


Ignore:
Timestamp:
04/25/2007 12:49:57 AM (20 years ago)
Author:
rob1n
Message:

Allow number_format to be internationalized. Props nbachiyski. fixes #3677

Location:
trunk
Files:
5 edited

Legend:

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

    r5303 r5308  
    832832        $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
    833833
    834         $category->category_count = number_format( $category->category_count );
    835         $category->link_count = number_format( $category->link_count );
     834        $category->category_count = number_format_i18n( $category->category_count );
     835        $category->link_count = number_format_i18n( $category->link_count );
    836836        $posts_count = ( $category->category_count > 0 ) ? "<a href='edit.php?cat=$category->cat_ID'>$category->category_count</a>" : $category->category_count;
    837837        return "<tr id='cat-$category->cat_ID'$class>
  • trunk/wp-admin/index.php

    r5191 r5308  
    4444
    4545<?php if ( $numcomments ) : ?>
    46 <p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format($numcomments) ); ?> &raquo;</a></strong></p>
     46<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format_i18n($numcomments) ); ?> &raquo;</a></strong></p>
    4747<?php endif; ?>
    4848
    … …  
    104104$numcats  = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories");
    105105
    106 $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');
    107 $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');
    108 $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');
     106$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');
     107$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');
     108$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');
    109109?>
    110110
  • trunk/wp-includes/functions.php

    r5304 r5308  
    8282        $j = @date($dateformatstring, $i);
    8383        return $j;
     84}
     85
     86function number_format_i18n($number, $decimals = null) {
     87        global $wp_locale;
     88        // let the user override the precision only
     89        $decimals = is_null($decimals)? $wp_locale->number_format['decimals'] : intval($decimals);
     90
     91        return number_format($number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']);
    8492}
    8593
  • trunk/wp-includes/locale.php

    r5062 r5308  
    8888                $this->meridiem['PM'] = __('PM');
    8989
     90                // Numbers formatting
     91                // See http://php.net/number_format
     92
     93                $trans = __('number_format_decimals');
     94                $this->number_format['decimals'] = ('number_format_decimals' == $trans) ? 0 : $trans;
     95               
     96                $trans = __('number_format_decimal_point');
     97                $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
     98
     99                $trans = __('number_format_thousands_sep');     
     100                $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
     101               
    90102                // Import global locale vars set during inclusion of $locale.php.
    91103                foreach ( $this->locale_vars as $var ) {
  • trunk/wp-settings.php

    r5297 r5308  
    7070        $timeend = $mtime;
    7171        $timetotal = $timeend-$timestart;
    72         $r = number_format($timetotal, $precision);
     72        $r = number_format_i18n($timetotal, $precision);
    7373        if ( $display )
    7474                echo $r;
Note: See TracChangeset for help on using the changeset viewer.