Make WordPress Core

Changeset 35878


Ignore:
Timestamp:
12/12/2015 01:34:33 AM (9 years ago)
Author:
SergeyBiryukov
Message:

I18N: In wp_maybe_decline_date(), bail early if translation functions are not available, e.g. in SHORTINIT mode.

Fixes #34967 for trunk.

File:
1 edited

Legend:

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

    r35685 r35878  
    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.