Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

Commit

Permalink
I18N: Reduce use of context functions and improve translator comments (
Browse files Browse the repository at this point in the history
…#733)

* Improve context and comment for copyright date format
* Remove context for jump to top labels, improve comment
* Remove context for search results string, improve comment, use number_format_i18n()
* Remove context from byline string to merge two strings
* Remove unnecessary context from search form labels
* Move translator comment above function call
* PHPCS: Change rule to ignore warning
  • Loading branch information
ocean90 authored and carolinan committed Oct 3, 2019
1 parent 303e31c commit d2c87cb
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion 404.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<?php
get_search_form(
array(
'label' => _x( '404 not found', 'Label', 'twentytwenty' ),
'label' => __( '404 not found', 'twentytwenty' ),
)
);
?>
Expand Down
14 changes: 7 additions & 7 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @since 1.0.0
*/

?>
?>
<footer id="site-footer" role="contentinfo" class="header-footer-group">

<div class="section-inner">
Expand All @@ -22,8 +22,8 @@
<?php
echo esc_html(
date_i18n(
/* Translators: Y = Format parameter for date() https://php.net/manual/en/function.date.php */
_x( 'Y', 'Translators: Y = Current year', 'twentytwenty' )
/* translators: Copyright date format, see https://secure.php.net/date */
_x( 'Y', 'copyright date format', 'twentytwenty' )
)
);
?>
Expand All @@ -43,14 +43,14 @@
<a class="to-the-top" href="#site-header">
<span class="to-the-top-long">
<?php
// Translators: %s = HTML character for an arrow.
printf( esc_html( _x( 'To the top %s', '%s = HTML character for an arrow', 'twentytwenty' ) ), '<span class="arrow">&uarr;</span>' );
/* translators: %s: HTML character for up arrow */
printf( esc_html( __( 'To the top %s', 'twentytwenty' ) ), '<span class="arrow">&uarr;</span>' );
?>
</span><!-- .to-the-top-long -->
<span class="to-the-top-short">
<?php
// Translators: %s = HTML character for an arrow.
printf( esc_html( _x( 'Up %s', '%s = HTML character for an arrow', 'twentytwenty' ) ), '<span class="arrow">&uarr;</span>' );
/* translators: %s: HTML character for up arrow */
printf( esc_html( __( 'Up %s', 'twentytwenty' ) ), '<span class="arrow">&uarr;</span>' );
?>
</span><!-- .to-the-top-short -->
</a><!-- .to-the-top -->
Expand Down
4 changes: 2 additions & 2 deletions inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ function twentytwenty_get_post_meta( $post_id = null, $location = 'single-top' )
<span class="meta-text">
<?php
printf(
// Translators: %s = the author name.
_x( 'By %s', '%s = author name', 'twentytwenty' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- core trusts translations
/* translators: %s: Author name */
__( 'By %s', 'twentytwenty' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- core trusts translations
'<a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author_meta( 'display_name' ) ) . '</a>'
);
?>
Expand Down
14 changes: 11 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@
);

if ( $wp_query->found_posts ) {
/* Translators: %s = Number of results */
$archive_subtitle = sprintf( _nx( 'We found %s result for your search.', 'We found %s results for your search.', $wp_query->found_posts, '%s = Number of results', 'twentytwenty' ), $wp_query->found_posts );
$archive_subtitle = sprintf(
/* translators: %s: Number of search results */
_n(
'We found %s result for your search.',
'We found %s results for your search.',
$wp_query->found_posts,
'twentytwenty'
),
number_format_i18n( $wp_query->found_posts )
);
} else {
$archive_subtitle = __( 'We could not find any results for your search. You can give it another try through the search form below.', 'twentytwenty' );
}
Expand Down Expand Up @@ -88,7 +96,7 @@
<?php
get_search_form(
array(
'label' => _x( 'search again', 'Label', 'twentytwenty' ),
'label' => __( 'search again', 'twentytwenty' ),
)
);
?>
Expand Down
2 changes: 1 addition & 1 deletion searchform.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
?>
<form role="search" <?php echo $aria_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped above. ?> method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label for="<?php echo esc_attr( $unique_id ); ?>">
<span class="screen-reader-text"><?php echo _x( 'Search for:', 'label', 'twentytwenty' ); // phpcs:ignore: WordPress.Security.EscapeOutput.OutputNotEscaped -- core trusts translations ?></span>
<span class="screen-reader-text"><?php _e( 'Search for:', 'twentytwenty' ); // phpcs:ignore: WordPress.Security.EscapeOutput.UnsafePrintingFunction -- core trusts translations ?></span>
<input type="search" id="<?php echo esc_attr( $unique_id ); ?>" class="search-field" placeholder="<?php echo esc_attr_x( 'Search &hellip;', 'placeholder', 'twentytwenty' ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
</label>
<input type="submit" class="search-submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'twentytwenty' ); ?>" />
Expand Down
4 changes: 2 additions & 2 deletions template-parts/entry-author-bio.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<span class="author-name">
<?php
printf(
/* Translators: %s: post author */
/* translators: %s: Author name */
__( 'By %s', 'twentytwenty' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- core trusts translations
esc_html( get_the_author() )
esc_html( get_the_author() )
);
?>
</span>
Expand Down
2 changes: 1 addition & 1 deletion template-parts/modal-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<?php
get_search_form(
array(
'label' => _x( 'Search for:', 'Label', 'twentytwenty' ),
'label' => __( 'Search for:', 'twentytwenty' ),
)
);
?>
Expand Down

0 comments on commit d2c87cb

Please sign in to comment.