From 2c3c216752adad2f136ddcbb8f6de2016370312b Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Tue, 22 Dec 2020 16:13:51 +0000 Subject: [PATCH] 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. Fixes #52047. git-svn-id: https://develop.svn.wordpress.org/trunk@49866 602fd350-edb4-49c9-b593-d223f7449a82 --- .../themes/twentytwentyone/comments.php | 3 +- .../twentytwentyone/inc/template-tags.php | 36 ++++++++----------- .../themes/twentytwentyone/single.php | 17 ++------- 3 files changed, 18 insertions(+), 38 deletions(-) diff --git a/src/wp-content/themes/twentytwentyone/comments.php b/src/wp-content/themes/twentytwentyone/comments.php index 85f538031d..edb96c7e43 100644 --- a/src/wp-content/themes/twentytwentyone/comments.php +++ b/src/wp-content/themes/twentytwentyone/comments.php @@ -59,8 +59,7 @@ $twenty_twenty_one_comment_count = get_comments_number(); esc_html__( 'Page ', 'twentytwentyone' ), + 'before_page_number' => esc_html__( 'Page', 'twentytwentyone' ) . ' ', 'mid_size' => 0, 'prev_text' => sprintf( '%s %s', diff --git a/src/wp-content/themes/twentytwentyone/inc/template-tags.php b/src/wp-content/themes/twentytwentyone/inc/template-tags.php index 38add801c5..35c428bfad 100644 --- a/src/wp-content/themes/twentytwentyone/inc/template-tags.php +++ b/src/wp-content/themes/twentytwentyone/inc/template-tags.php @@ -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 %s', 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' ), - '' . esc_html( $post_type_name ) . '' + wp_kses( + __( 'Newer posts', 'twentytwentyone' ), + array( + 'span' => array( + 'class' => array(), + ), + ) ) ), 'next_text' => sprintf( '%s %s', - sprintf( - /* translators: %s: The post-type name. */ - esc_html__( 'Older %s', 'twentytwentyone' ), - '' . esc_html( $post_type_name ) . '' + wp_kses( + __( 'Older posts', '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' ) ), diff --git a/src/wp-content/themes/twentytwentyone/single.php b/src/wp-content/themes/twentytwentyone/single.php index a0c6d2b10a..c550e64b81 100644 --- a/src/wp-content/themes/twentytwentyone/single.php +++ b/src/wp-content/themes/twentytwentyone/single.php @@ -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(