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.
Built from https://develop.svn.wordpress.org/branches/5.6@49869


git-svn-id: http://core.svn.wordpress.org/branches/5.6@49588 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2020-12-22 16:21:04 +00:00
parent e96048d2f0
commit 5990e9abc4
4 changed files with 19 additions and 39 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(

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6.1-alpha-49868';
$wp_version = '5.6.1-alpha-49869';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.