WordPress.org

Make WordPress Core

Changeset 35884


Ignore:
Timestamp:
12/12/2015 02:05:37 AM (4 years ago)
Author:
SergeyBiryukov
Message:

I18N: In WP_Locale::init(), replace space as a thousands separator with a non-breaking space.

  • If PHP version is 5.4.0 or greater, a regular space as a thousands separator is replaced with a non-breaking space, decoded using the blog_charset option.
  • If PHP version is 5.2.x or 5.3.x,   or   as a thousands separator is replaced with a regular space, as multiple bytes are not supported there.

Fixes #10373.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/locale.php

    r35879 r35884  
    188188
    189189        /* translators: $thousands_sep argument for http://php.net/number_format, default is , */
    190         $trans = __('number_format_thousands_sep');
    191         $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
     190        $thousands_sep = __( 'number_format_thousands_sep' );
     191
     192        if ( version_compare( PHP_VERSION, '5.4', '>=' ) ) {
     193            // Replace space with a non-breaking space to avoid wrapping.
     194            $non_breaking_space = html_entity_decode( ' ', ENT_QUOTES, get_option( 'blog_charset' ) );
     195            $thousands_sep = str_replace( ' ', $non_breaking_space, $thousands_sep );
     196        } else {
     197            // PHP < 5.4.0 does not support multiple bytes in thousands separator.
     198            $thousands_sep = str_replace( array( '&nbsp;', '&#160;' ), ' ', $thousands_sep );
     199        }
     200
     201        $this->number_format['thousands_sep'] = ( 'number_format_thousands_sep' === $thousands_sep ) ? ',' : $thousands_sep;
    192202
    193203        /* translators: $dec_point argument for http://php.net/number_format, default is . */
    194         $trans = __('number_format_decimal_point');
    195         $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
     204        $decimal_point = __( 'number_format_decimal_point' );
     205
     206        $this->number_format['decimal_point'] = ( 'number_format_decimal_point' === $decimal_point ) ? '.' : $decimal_point;
    196207
    197208        // Set text direction.
Note: See TracChangeset for help on using the changeset viewer.