WordPress.org

Make WordPress Core

Changeset 30300


Ignore:
Timestamp:
11/11/2014 01:24:01 PM (5 years ago)
Author:
boonebgorges
Message:

Improve localization for WP_Date_Query error strings.

  • Don't create an extra variable for the string when it's only used once.
  • Avoid using <code> HTML tags inside of translatable string.
  • Improve data types and escaping on sprintfed values.

Props dd32.
Fixes #25834.

File:
1 edited

Legend:

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

    r30150 r30300  
    299299        }
    300300
    301         // Message template for the min-max-check.
    302         /* translators: Date query invalid date message: 1: invalid value, 2: type of value, 3: minimum valid value, 4: maximum valid value */
    303         $min_max_msg = __( 'Invalid value <code>%1$s</code> for <strong>%2$s</strong>. Excepted value should between <code>%3$d</code> and </code>%4$d</code>.' );
    304 
    305301        // Array containing all min-max checks.
    306302        $min_max_checks = array();
     
    388384
    389385            if ( ! $is_between ) {
     386
    390387                $error = sprintf(
    391                     $min_max_msg,
    392                     esc_html( $date_query[ $key ] ),
    393                     $key,
    394                     $check['min'],
    395                     $check['max']
     388                    /* translators: Date query invalid date message: 1: invalid value, 2: type of value, 3: minimum valid value, 4: maximum valid value */
     389                    __( 'Invalid value %1$s for %2$s. Expected value should between %3$s and %4$s.' ),
     390                    '<code>' . esc_html( $date_query[ $key ] ) . '</code>',
     391                    '<code>' . esc_html( $key ) . '</code>',
     392                    '<code>' . esc_html( $check['min'] ) . '</code>',
     393                    '<code>' . esc_html( $check['max'] ) . '</code>'
    396394                );
    397395
     
    418416                /* translators: 1: year, 2: month, 3: day of month */
    419417                $day_month_year_error_msg = sprintf(
    420                     __( 'The following values do not describe a valid date: year <code>%1$s</code>, month <code>%2$s</code>, day <code>%3$s</code>.' ),
    421                     esc_html( $date_query['year'] ),
    422                     esc_html( $date_query['month'] ),
    423                     esc_html( $date_query['day'] )
     418                    __( 'The following values do not describe a valid date: year %1$s, month %2$s, day %3$s.' ),
     419                    '<code>' . esc_html( $date_query['year'] ) . '</code>',
     420                    '<code>' . esc_html( $date_query['month'] ) . '</code>',
     421                    '<code>' . esc_html( $date_query['day'] ) . '</code>'
    424422                );
    425423
Note: See TracChangeset for help on using the changeset viewer.