WordPress.org

Make WordPress Core

Ticket #3677: number-format-i18n.diff

File number-format-i18n.diff, 1.7 KB (added by nbachiyski, 14 years ago)

number_format_i18n function

  • wp-includes/functions.php

     
    8080        return $j;
    8181}
    8282
     83function number_format_i18n($number, $decimals = null) {
     84        global $wp_locale;
     85        // let the user override the precision only
     86        $decimals = is_null($decimals)? $wp_locale->number_format['decimals'] : intval($decimals);
     87
     88        return number_format($number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']);
     89}
     90
    8391function get_weekstartend($mysqlstring, $start_of_week) {
    8492        $my = substr($mysqlstring,0,4);
    8593        $mm = substr($mysqlstring,8,2);
  • wp-includes/locale.php

     
    8787                $this->meridiem['AM'] = __('AM');
    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 ) {
    92104                        if ( isset($GLOBALS[$var]) )
     
    138150        }
    139151}
    140152
    141 ?>
    142  No newline at end of file
     153?>