Make WordPress Core

Ticket #11226: 11226.3.diff

File 11226.3.diff, 5.5 KB (added by SergeyBiryukov, 10 years ago)
  • src/wp-includes/default-filters.php

     
    157157
    158158add_filter( 'wp_sprintf', 'wp_sprintf_l', 10, 2 );
    159159
     160add_filter( 'date_i18n', 'wp_maybe_decline_date' );
     161
    160162// RSS filters
    161163add_filter( 'the_title_rss',      'strip_tags'                    );
    162164add_filter( 'the_title_rss',      'ent2ncr',                    8 );
  • src/wp-includes/functions.php

     
    159159}
    160160
    161161/**
     162 * Determines if the date should be declined.
     163 *
     164 * If the locale specifies that month names require a genitive case in certain
     165 * formats (like 'j F Y'), the month name will be replaced with a correct form.
     166 *
     167 * @since 4.4.0
     168 *
     169 * @param string $date Formatted date string.
     170 * @return string The date, declined if locale specifies it.
     171 */
     172function wp_maybe_decline_date( $date ) {
     173        global $wp_locale;
     174
     175        /* translators: If months in your language require a genitive case,
     176         * translate this to 'on'. Do not translate into your own language.
     177         */
     178        if ( 'on' === _x( 'off', 'decline months names: on or off' ) ) {
     179                // Match a format like 'j F Y' or 'j. F'
     180                if ( @preg_match( '#^\d{1,2}\.? \w+#u', $date ) ) {
     181                        $months = $wp_locale->month;
     182
     183                        foreach ( $months as $key => $month ) {
     184                                $months[ $key ] = '#' . $month . '#';
     185                        }
     186
     187                        $date = preg_replace( $months, $wp_locale->month_genitive, $date );
     188                }
     189        }
     190
     191        // Used for locale-specific rules
     192        $locale = get_locale();
     193
     194        if ( 'ca' === $locale ) {
     195                // " de abril| de agost| de octubre..." -> " d'abril| d'agost| d'octubre..."
     196                $date = preg_replace( '# de ([ao])#i', " d'\\1", $date );
     197        }
     198
     199        return $date;
     200}
     201
     202/**
    162203 * Convert integer number to format based on the locale.
    163204 *
    164205 * @since 2.3.0
  • src/wp-includes/locale.php

     
    128128                $this->weekday_abbrev[__('Saturday')]  = /* translators: three-letter abbreviation of the weekday */ __('Sat');
    129129
    130130                // The Months
    131                 $this->month['01'] = /* translators: month name */ __('January');
    132                 $this->month['02'] = /* translators: month name */ __('February');
    133                 $this->month['03'] = /* translators: month name */ __('March');
    134                 $this->month['04'] = /* translators: month name */ __('April');
    135                 $this->month['05'] = /* translators: month name */ __('May');
    136                 $this->month['06'] = /* translators: month name */ __('June');
    137                 $this->month['07'] = /* translators: month name */ __('July');
    138                 $this->month['08'] = /* translators: month name */ __('August');
    139                 $this->month['09'] = /* translators: month name */ __('September');
    140                 $this->month['10'] = /* translators: month name */ __('October');
    141                 $this->month['11'] = /* translators: month name */ __('November');
    142                 $this->month['12'] = /* translators: month name */ __('December');
     131                $this->month['01'] = /* translators: month name */ __( 'January' );
     132                $this->month['02'] = /* translators: month name */ __( 'February' );
     133                $this->month['03'] = /* translators: month name */ __( 'March' );
     134                $this->month['04'] = /* translators: month name */ __( 'April' );
     135                $this->month['05'] = /* translators: month name */ __( 'May' );
     136                $this->month['06'] = /* translators: month name */ __( 'June' );
     137                $this->month['07'] = /* translators: month name */ __( 'July' );
     138                $this->month['08'] = /* translators: month name */ __( 'August' );
     139                $this->month['09'] = /* translators: month name */ __( 'September' );
     140                $this->month['10'] = /* translators: month name */ __( 'October' );
     141                $this->month['11'] = /* translators: month name */ __( 'November' );
     142                $this->month['12'] = /* translators: month name */ __( 'December' );
    143143
     144                // The Months, genitive
     145                $this->month_genitive['01'] = /* translators: month name, genitive */ _x( 'January', 'genitive' );
     146                $this->month_genitive['02'] = /* translators: month name, genitive */ _x( 'February', 'genitive' );
     147                $this->month_genitive['03'] = /* translators: month name, genitive */ _x( 'March', 'genitive' );
     148                $this->month_genitive['04'] = /* translators: month name, genitive */ _x( 'April', 'genitive' );
     149                $this->month_genitive['05'] = /* translators: month name, genitive */ _x( 'May', 'genitive' );
     150                $this->month_genitive['06'] = /* translators: month name, genitive */ _x( 'June', 'genitive' );
     151                $this->month_genitive['07'] = /* translators: month name, genitive */ _x( 'July', 'genitive' );
     152                $this->month_genitive['08'] = /* translators: month name, genitive */ _x( 'August', 'genitive' );
     153                $this->month_genitive['09'] = /* translators: month name, genitive */ _x( 'September', 'genitive' );
     154                $this->month_genitive['10'] = /* translators: month name, genitive */ _x( 'October', 'genitive' );
     155                $this->month_genitive['11'] = /* translators: month name, genitive */ _x( 'November', 'genitive' );
     156                $this->month_genitive['12'] = /* translators: month name, genitive */ _x( 'December', 'genitive' );
     157
    144158                // Abbreviations for each month.
    145159                $this->month_abbrev[ __( 'January' ) ]   = /* translators: three-letter abbreviation of the month */ _x( 'Jan', 'January abbreviation' );
    146160                $this->month_abbrev[ __( 'February' ) ]  = /* translators: three-letter abbreviation of the month */ _x( 'Feb', 'February abbreviation' );