WordPress.org

Make WordPress Core

Opened 2 weeks ago

Last modified 2 weeks ago

#44531 new defect (bug)

Multiple bytes decimal point and thousands separator in number_format_i18n PHP < 5.4

Reported by: remcotolsma Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: I18N Keywords: has-patch has-unit-tests dev-feedback 2nd-opinion
Focuses: Cc:

Description

PHP number_format has only multiple bytes support in the decimal point and thousands separator parameters since PHP 5.4.0. There is some code in place in wp-includes/class-wp-locale.php to work around this:

<?php

if ( version_compare( PHP_VERSION, '5.4', '>=' ) ) {
        // Replace space with a non-breaking space to avoid wrapping.
        $thousands_sep = str_replace( ' ', '&nbsp;', $thousands_sep );
} else {
        // PHP < 5.4.0 does not support multiple bytes in thousands separator.
        $thousands_sep = str_replace( array( '&nbsp;', '&#160;' ), ' ', $thousands_sep );
}

Since we don't know how translators translate number_format_thousands_sep and number_format_decimal_point i don't think this is working in all cases. In the French translation files there is currently a multibyte non-breaking space char. Above code will not replace the multibyte non-breaking space char to a regular space.

Also see: https://make.wordpress.org/polyglots/2013/06/24/number_format-bug/.

https://translate.wordpress.org/projects/wp/4.8.x/fr/default?filters%5Bstatus%5D=either&filters%5Boriginal_id%5D=5138840&filters%5Btranslation_id%5D=51885045

Attachments (1)

mb-support-number_format_i18n-old-php.diff (3.5 KB) - added by remcotolsma 2 weeks ago.

Download all attachments as: .zip

Change History (2)

Note: See TracTickets for help on using tickets.