[wp-trac] [WordPress Trac] #48319: About wp_date function when locale is 'ja'

WordPress Trac noreply at wordpress.org
Wed Oct 16 03:05:23 UTC 2019


#48319: About wp_date function when locale is 'ja'
--------------------------+-----------------------------
 Reporter:  tmatsuur      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Version 5.3 adds the wp_date function.

 If locale is 'ja' and 'F' is specified for the parameter of this function,
 an extra backslash is added to the return value.

 Try dumping the return value of wp_date function and date_i18n function.
 {{{
 var_dump( wp_date( 'F' ), date_i18n( 'F' ) );
 }}}

 Dumped contents.
 {{{
 string(6) "\10月"
 string(6) "\10月"
 }}}

 In the previous version, the return value of the date_i18n function has no
 backslash.

 {{{
 string(5) "10月"
 }}}

 I think the cause is in the part where the format is converted according
 to the locale.

 wp-includes/functions.php : 259 - 261

 {{{
 case 'F':
         $new_format .= backslashit( $month );
         break;
 }}}

 This $new_format variable is used as is in the format method.
 {{{
 $date = $datetime->format( $new_format );
 }}}

 The date_i18n function of version 5.2.4 uses the preg_replace function
 during format conversion.
 {{{
 $dateformatstring     = preg_replace( '/([^\\\])F/', "\\1" . backslashit(
 $datemonth ), $dateformatstring );
 }}}

 Since wp_date function does not use preg_replace function, I don't think
 it is necessary to use backslashit function.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48319>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list