Make WordPress Core


Ignore:
Timestamp:
03/18/2014 06:49:03 PM (12 years ago)
Author:
lancewillett
Message:

Twenty Fourteen: improve i18n in Ephemera widget for better translation of plurals for post format archives. Fixes #27069, props Chouby, SergeyBiryukov, lancewillett.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfourteen/inc/widgets.php

    r27412 r27589  
    2525
    2626        /**
    27          * Pluralized post format strings.
    28          *
    29          * @access private
    30          * @since Twenty Fourteen 1.0
    31          *
    32          * @var array
    33          */
    34         private $format_strings;
    35 
    36         /**
    3727         * Constructor.
    3828         *
     
    4636                        'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ),
    4737                ) );
    48 
    49                 /*
    50                  * @todo http://core.trac.wordpress.org/ticket/23257: Add plural versions of Post Format strings
    51                  */
    52                 $this->format_strings = array(
    53                         'aside'   => __( 'Asides',    'twentyfourteen' ),
    54                         'image'   => __( 'Images',    'twentyfourteen' ),
    55                         'video'   => __( 'Videos',    'twentyfourteen' ),
    56                         'audio'   => __( 'Audio',     'twentyfourteen' ),
    57                         'quote'   => __( 'Quotes',    'twentyfourteen' ),
    58                         'link'    => __( 'Links',     'twentyfourteen' ),
    59                         'gallery' => __( 'Galleries', 'twentyfourteen' ),
    60                 );
    6138        }
    6239
     
    7350        public function widget( $args, $instance ) {
    7451                $format = $instance['format'];
     52
     53                switch ( $format ) {
     54                        case 'image':
     55                                $format_string      = __( 'Images', 'twentyfourteen' );
     56                                $format_string_more = __( 'More images', 'twentyfourteen' );
     57                                break;
     58                        case 'video':
     59                                $format_string      = __( 'Videos', 'twentyfourteen' );
     60                                $format_string_more = __( 'More videos', 'twentyfourteen' );
     61                                break;
     62                        case 'audio':
     63                                $format_string      = __( 'Audio', 'twentyfourteen' );
     64                                $format_string_more = __( 'More audio', 'twentyfourteen' );
     65                                break;
     66                        case 'quote':
     67                                $format_string      = __( 'Quotes', 'twentyfourteen' );
     68                                $format_string_more = __( 'More quotes', 'twentyfourteen' );
     69                                break;
     70                        case 'link':
     71                                $format_string      = __( 'Links', 'twentyfourteen' );
     72                                $format_string_more = __( 'More links', 'twentyfourteen' );
     73                                break;
     74                        case 'gallery':
     75                                $format_string      = __( 'Galleries', 'twentyfourteen' );
     76                                $format_string_more = __( 'More galleries', 'twentyfourteen' );
     77                                break;
     78                        case 'aside':
     79                        default:
     80                                $format_string      = __( 'Asides', 'twentyfourteen' );
     81                                $format_string_more = __( 'More asides', 'twentyfourteen' );
     82                                break;
     83                }
     84
    7585                $number = empty( $instance['number'] ) ? 2 : absint( $instance['number'] );
    76                 $title  = apply_filters( 'widget_title', empty( $instance['title'] ) ? $this->format_strings[ $format ] : $instance['title'], $instance, $this->id_base );
     86                $title  = apply_filters( 'widget_title', empty( $instance['title'] ) ? $format_string : $instance['title'], $instance, $this->id_base );
    7787
    7888                $ephemera = new WP_Query( array(
     
    192202
    193203                        </ol>
    194                         <a class="post-format-archive-link" href="<?php echo esc_url( get_post_format_link( $format ) ); ?>"><?php printf( __( 'More %s <span class="meta-nav">&rarr;</span>', 'twentyfourteen' ), $this->format_strings[ $format ] ); ?></a>
     204                        <a class="post-format-archive-link" href="<?php echo esc_url( get_post_format_link( $format ) ); ?>">
     205                                <?php
     206                                        /* translators: used with More archives link */
     207                                        printf( __( '%s <span class="meta-nav">&rarr;</span>', 'twentyfourteen' ), $format_string_more );
     208                                ?>
     209                        </a>
    195210                        <?php
    196211
Note: See TracChangeset for help on using the changeset viewer.