Twenty Twenty-One: Improve strings found in post navigations for easier translating.

This change adjusts strings found within post navigations to ensure translators are provided the full context needed to properly translate.

Props poena, SergeyBiryukov, aristath.
Merges [49866] to the 5.6 branch.
Fixes #52047.

git-svn-id: https://develop.svn.wordpress.org/branches/5.6@49869 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2020-12-22 16:19:26 +00:00
parent 1b281e4be2
commit caaf33c607
3 changed files with 18 additions and 38 deletions

View File

@ -59,8 +59,7 @@ $twenty_twenty_one_comment_count = get_comments_number();
<?php
the_comments_pagination(
array(
/* translators: There is a space after page. */
'before_page_number' => esc_html__( 'Page ', 'twentytwentyone' ),
'before_page_number' => esc_html__( 'Page', 'twentytwentyone' ) . ' ',
'mid_size' => 0,
'prev_text' => sprintf(
'%s <span class="nav-prev-text">%s</span>',

View File

@ -223,37 +223,31 @@ if ( ! function_exists( 'twenty_twenty_one_the_posts_navigation' ) ) {
* @return void
*/
function twenty_twenty_one_the_posts_navigation() {
$post_type = get_post_type_object( get_post_type() );
$post_type_name = '';
if (
is_object( $post_type ) &&
property_exists( $post_type, 'labels' ) &&
is_object( $post_type->labels ) &&
property_exists( $post_type->labels, 'name' )
) {
$post_type_name = $post_type->labels->name;
}
the_posts_pagination(
array(
/* translators: There is a space after page. */
'before_page_number' => esc_html__( 'Page ', 'twentytwentyone' ),
'before_page_number' => esc_html__( 'Page', 'twentytwentyone' ) . ' ',
'mid_size' => 0,
'prev_text' => sprintf(
'%s <span class="nav-prev-text">%s</span>',
is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ),
sprintf(
/* translators: %s: The post-type name. */
esc_html__( 'Newer %s', 'twentytwentyone' ),
'<span class="nav-short">' . esc_html( $post_type_name ) . '</span>'
wp_kses(
__( 'Newer <span class="nav-short">posts</span>', 'twentytwentyone' ),
array(
'span' => array(
'class' => array(),
),
)
)
),
'next_text' => sprintf(
'<span class="nav-next-text">%s</span> %s',
sprintf(
/* translators: %s: The post-type name. */
esc_html__( 'Older %s', 'twentytwentyone' ),
'<span class="nav-short">' . esc_html( $post_type_name ) . '</span>'
wp_kses(
__( 'Older <span class="nav-short">posts</span>', 'twentytwentyone' ),
array(
'span' => array(
'class' => array(),
),
)
),
is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' )
),

View File

@ -36,21 +36,8 @@ while ( have_posts() ) :
$twentytwentyone_next = is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' );
$twentytwentyone_prev = is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' );
$twentytwentyone_post_type = get_post_type_object( get_post_type() );
$twentytwentyone_post_type_name = '';
if (
is_object( $twentytwentyone_post_type ) &&
property_exists( $twentytwentyone_post_type, 'labels' ) &&
is_object( $twentytwentyone_post_type->labels ) &&
property_exists( $twentytwentyone_post_type->labels, 'singular_name' )
) {
$twentytwentyone_post_type_name = $twentytwentyone_post_type->labels->singular_name;
}
/* translators: %s: The post-type singular name (example: Post, Page, etc.) */
$twentytwentyone_next_label = sprintf( esc_html__( 'Next %s', 'twentytwentyone' ), $twentytwentyone_post_type_name );
/* translators: %s: The post-type singular name (example: Post, Page, etc.) */
$twentytwentyone_previous_label = sprintf( esc_html__( 'Previous %s', 'twentytwentyone' ), $twentytwentyone_post_type_name );
$twentytwentyone_next_label = esc_html__( 'Next post', 'twentytwentyone' );
$twentytwentyone_previous_label = esc_html__( 'Previous post', 'twentytwentyone' );
the_post_navigation(
array(