Coding Standards: Fix the minor `WordPress.WP.I18n` violations.

`WordPress.WP.I18n.MissingTranslatorsComment` is in progress in #44360.

See #45934.


Built from https://develop.svn.wordpress.org/trunk@44562


git-svn-id: http://core.svn.wordpress.org/trunk@44393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2019-01-11 06:04:49 +00:00
parent e05b19d248
commit c008959e9e
12 changed files with 58 additions and 9 deletions

View File

@ -65,8 +65,10 @@ foreach ( $credits['groups'] as $group_slug => $group_data ) {
// Considered a special slug in the API response. (Also, will never be returned for en_US.)
$title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' );
} elseif ( isset( $group_data['placeholders'] ) ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
$title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] );
} else {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
$title = translate( $group_data['name'] );
}
@ -100,6 +102,7 @@ foreach ( $credits['groups'] as $group_slug => $group_data ) {
echo '<img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" />' . "\n";
echo esc_html( $person_data[0] ) . "</a>\n\t";
if ( ! $compact ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n";
}
echo "</li>\n";

View File

@ -167,8 +167,10 @@ function wp_get_popular_importers() {
}
foreach ( $popular_importers['importers'] as &$importer ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
$importer['description'] = translate( $importer['description'] );
if ( $importer['name'] != 'WordPress' ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
$importer['name'] = translate( $importer['name'] );
}
}

View File

@ -137,6 +137,7 @@ function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup
}
if ( $textdomain ) {
foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
$plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
}
}

View File

@ -31,11 +31,20 @@
<?php if ( have_comments() ) : ?>
<h2 id="comments-title">
<?php
if ( 1 === get_comments_number() ) {
printf(
_n( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'twentyeleven' ),
/* translators: %s: The post title. */
__( 'One thought on &ldquo;%1$s&rdquo;', 'twentyeleven' ),
'<span>' . get_the_title() . '</span>'
);
} else {
printf(
/* translators: %1$s: The number of comments. %2$s: The post title. */
_n( '%1$s thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'twentyeleven' ),
number_format_i18n( get_comments_number() ),
'<span>' . get_the_title() . '</span>'
);
}
?>
</h2>

View File

@ -34,11 +34,20 @@
<?php if ( have_comments() ) : ?>
<h3 id="comments-title">
<?php
printf(
_n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'twentyten' ),
number_format_i18n( get_comments_number() ),
'<em>' . get_the_title() . '</em>'
);
if ( 1 === get_comments_number() ) {
printf(
/* translators: %s: The post title. */
__( 'One Response to %s', 'twentyten' ),
'<em>' . get_the_title() . '</em>'
);
} else {
/* translators: %1$s: The number of comments. %2$s: The post title. */
printf(
_n( '%1$s Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'twentyten' ),
number_format_i18n( get_comments_number() ),
'<em>' . get_the_title() . '</em>'
);
}
?>
</h3>

View File

@ -23,11 +23,20 @@ if ( post_password_required() ) {
<?php if ( have_comments() ) : ?>
<h2 class="comments-title">
<?php
if ( 1 === get_comments_number() ) {
printf(
_nx( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'twentythirteen' ),
/* translators: %s: The post title. */
_x( 'One thought on &ldquo;%s&rdquo;', 'comments title', 'twentythirteen' ),
'<span>' . get_the_title() . '</span>'
);
} else {
printf(
/* translators: %1$s: The number of comments. %2$s: The post title. */
_nx( '%1$s thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'twentythirteen' ),
number_format_i18n( get_comments_number() ),
'<span>' . get_the_title() . '</span>'
);
}
?>
</h2>

View File

@ -29,11 +29,20 @@ if ( post_password_required() ) {
<?php if ( have_comments() ) : ?>
<h2 class="comments-title">
<?php
if ( 1 === get_comments_number() ) {
printf(
_n( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'twentytwelve' ),
/* translators: %s: The post title. */
__( 'One thought on &ldquo;%s&rdquo;', 'twentytwelve' ),
'<span>' . get_the_title() . '</span>'
);
} else {
printf(
/* translators: %1$s: The number of comments. %2$s: The post title. */
_n( '%1$s thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'twentytwelve' ),
number_format_i18n( get_comments_number() ),
'<span>' . get_the_title() . '</span>'
);
}
?>
</h2>

View File

@ -836,12 +836,14 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
} elseif ( ! empty( $args['topic_count_text_callback'] ) ) {
// Look for the alternative callback style. Ignore the previous default.
if ( $args['topic_count_text_callback'] === 'default_topic_count_text' ) {
// wpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralSingle,WordPress.WP.I18n.NonSingularStringLiteralPlural
$translate_nooped_plural = _n_noop( '%s item', '%s items' );
} else {
$translate_nooped_plural = false;
}
} elseif ( isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) {
// If no callback exists, look for the old-style single_text and multiple_text arguments.
// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralSingle,WordPress.WP.I18n.NonSingularStringLiteralPlural
$translate_nooped_plural = _n_noop( $args['single_text'], $args['multiple_text'] );
} else {
// This is the default for when no callback, plural, or argument is passed in.

View File

@ -874,6 +874,7 @@ final class WP_Theme implements ArrayAccess {
if ( isset( $this->name_translated ) ) {
return $this->name_translated;
}
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
$this->name_translated = translate( $value, $this->get( 'TextDomain' ) );
return $this->name_translated;
case 'Tags':
@ -925,6 +926,7 @@ final class WP_Theme implements ArrayAccess {
return $value;
default:
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
$value = translate( $value, $this->get( 'TextDomain' ) );
}
return $value;

View File

@ -5073,6 +5073,7 @@ function wp_timezone_choice( $selected_zone, $locale = null ) {
$exists[4] = ( $exists[1] && $exists[3] );
$exists[5] = ( $exists[2] && $exists[3] );
// phpcs:disable WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
$zonen[] = array(
'continent' => ( $exists[0] ? $zone[0] : '' ),
'city' => ( $exists[1] ? $zone[1] : '' ),
@ -5081,6 +5082,7 @@ function wp_timezone_choice( $selected_zone, $locale = null ) {
't_city' => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ),
't_subcity' => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' ),
);
// phpcs:enable
}
usort( $zonen, '_wp_timezone_choice_usort_callback' );

View File

@ -1037,6 +1037,7 @@ function register_post_status( $post_status, $args = array() ) {
}
if ( false === $args->label_count ) {
// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralSingle,WordPress.WP.I18n.NonSingularStringLiteralPlural
$args->label_count = _n_noop( $args->label, $args->label );
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.1-beta1-44561';
$wp_version = '5.1-beta1-44562';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.