Twenty Fourteen: improve i18n in Ephemera widget for better translation of plurals for post format archives. Fixes #27069, props Chouby, SergeyBiryukov, lancewillett.
Built from https://develop.svn.wordpress.org/trunk@27589 git-svn-id: http://core.svn.wordpress.org/trunk@27432 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a96b9c80b5
commit
589709bc3a
|
@ -23,16 +23,6 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
|
||||||
*/
|
*/
|
||||||
private $formats = array( 'aside', 'image', 'video', 'audio', 'quote', 'link', 'gallery' );
|
private $formats = array( 'aside', 'image', 'video', 'audio', 'quote', 'link', 'gallery' );
|
||||||
|
|
||||||
/**
|
|
||||||
* Pluralized post format strings.
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @since Twenty Fourteen 1.0
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $format_strings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
@ -45,19 +35,6 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
|
||||||
'classname' => 'widget_twentyfourteen_ephemera',
|
'classname' => 'widget_twentyfourteen_ephemera',
|
||||||
'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ),
|
'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
/*
|
|
||||||
* @todo http://core.trac.wordpress.org/ticket/23257: Add plural versions of Post Format strings
|
|
||||||
*/
|
|
||||||
$this->format_strings = array(
|
|
||||||
'aside' => __( 'Asides', 'twentyfourteen' ),
|
|
||||||
'image' => __( 'Images', 'twentyfourteen' ),
|
|
||||||
'video' => __( 'Videos', 'twentyfourteen' ),
|
|
||||||
'audio' => __( 'Audio', 'twentyfourteen' ),
|
|
||||||
'quote' => __( 'Quotes', 'twentyfourteen' ),
|
|
||||||
'link' => __( 'Links', 'twentyfourteen' ),
|
|
||||||
'gallery' => __( 'Galleries', 'twentyfourteen' ),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,8 +49,41 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
|
||||||
*/
|
*/
|
||||||
public function widget( $args, $instance ) {
|
public function widget( $args, $instance ) {
|
||||||
$format = $instance['format'];
|
$format = $instance['format'];
|
||||||
|
|
||||||
|
switch ( $format ) {
|
||||||
|
case 'image':
|
||||||
|
$format_string = __( 'Images', 'twentyfourteen' );
|
||||||
|
$format_string_more = __( 'More images', 'twentyfourteen' );
|
||||||
|
break;
|
||||||
|
case 'video':
|
||||||
|
$format_string = __( 'Videos', 'twentyfourteen' );
|
||||||
|
$format_string_more = __( 'More videos', 'twentyfourteen' );
|
||||||
|
break;
|
||||||
|
case 'audio':
|
||||||
|
$format_string = __( 'Audio', 'twentyfourteen' );
|
||||||
|
$format_string_more = __( 'More audio', 'twentyfourteen' );
|
||||||
|
break;
|
||||||
|
case 'quote':
|
||||||
|
$format_string = __( 'Quotes', 'twentyfourteen' );
|
||||||
|
$format_string_more = __( 'More quotes', 'twentyfourteen' );
|
||||||
|
break;
|
||||||
|
case 'link':
|
||||||
|
$format_string = __( 'Links', 'twentyfourteen' );
|
||||||
|
$format_string_more = __( 'More links', 'twentyfourteen' );
|
||||||
|
break;
|
||||||
|
case 'gallery':
|
||||||
|
$format_string = __( 'Galleries', 'twentyfourteen' );
|
||||||
|
$format_string_more = __( 'More galleries', 'twentyfourteen' );
|
||||||
|
break;
|
||||||
|
case 'aside':
|
||||||
|
default:
|
||||||
|
$format_string = __( 'Asides', 'twentyfourteen' );
|
||||||
|
$format_string_more = __( 'More asides', 'twentyfourteen' );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$number = empty( $instance['number'] ) ? 2 : absint( $instance['number'] );
|
$number = empty( $instance['number'] ) ? 2 : absint( $instance['number'] );
|
||||||
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? $this->format_strings[ $format ] : $instance['title'], $instance, $this->id_base );
|
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? $format_string : $instance['title'], $instance, $this->id_base );
|
||||||
|
|
||||||
$ephemera = new WP_Query( array(
|
$ephemera = new WP_Query( array(
|
||||||
'order' => 'DESC',
|
'order' => 'DESC',
|
||||||
|
@ -191,7 +201,12 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
|
||||||
<?php endwhile; ?>
|
<?php endwhile; ?>
|
||||||
|
|
||||||
</ol>
|
</ol>
|
||||||
<a class="post-format-archive-link" href="<?php echo esc_url( get_post_format_link( $format ) ); ?>"><?php printf( __( 'More %s <span class="meta-nav">→</span>', 'twentyfourteen' ), $this->format_strings[ $format ] ); ?></a>
|
<a class="post-format-archive-link" href="<?php echo esc_url( get_post_format_link( $format ) ); ?>">
|
||||||
|
<?php
|
||||||
|
/* translators: used with More archives link */
|
||||||
|
printf( __( '%s <span class="meta-nav">→</span>', 'twentyfourteen' ), $format_string_more );
|
||||||
|
?>
|
||||||
|
</a>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo $args['after_widget'];
|
echo $args['after_widget'];
|
||||||
|
|
Loading…
Reference in New Issue