Make WordPress Core

Opened 6 years ago

Last modified 5 years ago

#44531 new defect (bug)

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

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


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:


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:

Attachments (1)

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

Download all attachments as: .zip

Change History (3)

Note: See TracTickets for help on using tickets.