From e20fb91e5436f4d766911b7de092314585edf8c2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 12 Dec 2015 02:06:35 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@35884 git-svn-id: http://core.svn.wordpress.org/trunk@35848 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/locale.php | 19 +++++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/wp-includes/locale.php b/wp-includes/locale.php index 040fa5563a..54a3c93891 100644 --- a/wp-includes/locale.php +++ b/wp-includes/locale.php @@ -187,12 +187,23 @@ class WP_Locale { // See http://php.net/number_format /* translators: $thousands_sep argument for http://php.net/number_format, default is , */ - $trans = __('number_format_thousands_sep'); - $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans; + $thousands_sep = __( 'number_format_thousands_sep' ); + + if ( version_compare( PHP_VERSION, '5.4', '>=' ) ) { + // Replace space with a non-breaking space to avoid wrapping. + $non_breaking_space = html_entity_decode( ' ', ENT_QUOTES, get_option( 'blog_charset' ) ); + $thousands_sep = str_replace( ' ', $non_breaking_space, $thousands_sep ); + } else { + // PHP < 5.4.0 does not support multiple bytes in thousands separator. + $thousands_sep = str_replace( array( ' ', ' ' ), ' ', $thousands_sep ); + } + + $this->number_format['thousands_sep'] = ( 'number_format_thousands_sep' === $thousands_sep ) ? ',' : $thousands_sep; /* 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; + $decimal_point = __( 'number_format_decimal_point' ); + + $this->number_format['decimal_point'] = ( 'number_format_decimal_point' === $decimal_point ) ? '.' : $decimal_point; // Set text direction. if ( isset( $GLOBALS['text_direction'] ) ) diff --git a/wp-includes/version.php b/wp-includes/version.php index 2acba86f46..e3c6b960ee 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-alpha-35883'; +$wp_version = '4.5-alpha-35884'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.