Make WordPress Core

Opened 8 years ago

Closed 4 months ago

#44531 closed defect (bug) (duplicate)

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

Reported by: remcotolsma's profile remcotolsma Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: I18N Keywords: has-patch has-unit-tests dev-feedback
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 8 years ago.

Download all attachments as: .zip

Change History (5)

#2 @pento
7 years ago

  • Version trunk deleted

#3 @callumbw95
4 months ago

  • Keywords close added

Hi @remcotolsma,

I have just come across this ticket now, and as WordPress no longer supports PHP below 7.2 in the latest release. WordPress actually dropped support for PHP 5.4 back in version 5.6 of WordPress.

As we are a good couple of major releases ahead of that version I am going to mark this ticket with the close tag.

#4 @sabernhardt
4 months ago

  • Keywords 2nd-opinion close removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #48074.

I'll close this. r46214 removed the PHP < 5.4 code from WP_Locale.

Note: See TracTickets for help on using tickets.