I18N: Use a consistent pattern for translator comments for placeholders in Customizer and widget strings.

Props danieltj, Rahmohn.
Fixes #41974.

git-svn-id: https://develop.svn.wordpress.org/trunk@41640 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2017-09-29 11:41:06 +00:00
parent b8d32950e7
commit 13b5f8272a
9 changed files with 23 additions and 25 deletions

View File

@ -35,7 +35,7 @@ get_current_screen()->add_help_tab( array(
'</ul>' . '</ul>' .
'<p>' . __( 'After typing in your edits, click Update File.' ) . '</p>' . '<p>' . __( 'After typing in your edits, click Update File.' ) . '</p>' .
'<p>' . __( '<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.' ) . '</p>' . '<p>' . __( '<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.' ) . '</p>' .
/* translators: placeholder is link to codex article about child themes */ /* translators: %s: link to codex article about child themes */
'<p>' . sprintf( __( 'Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a <a href="%s">child theme</a> instead.' ), __( 'https://codex.wordpress.org/Child_Themes' ) ) . '</p>' . '<p>' . sprintf( __( 'Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a <a href="%s">child theme</a> instead.' ), __( 'https://codex.wordpress.org/Child_Themes' ) ) . '</p>' .
( is_network_admin() ? '<p>' . __( 'Any edits to files from this screen will be reflected on all sites in the network.' ) . '</p>' : '' ), ( is_network_admin() ? '<p>' . __( 'Any edits to files from this screen will be reflected on all sites in the network.' ) . '</p>' : '' ),
) ); ) );

View File

@ -2616,7 +2616,7 @@ final class WP_Customize_Manager {
if ( $update_transactionally && $invalid_setting_count > 0 ) { if ( $update_transactionally && $invalid_setting_count > 0 ) {
$response = array( $response = array(
'setting_validities' => $setting_validities, 'setting_validities' => $setting_validities,
/* translators: placeholder is number of invalid settings */ /* translators: %s: number of invalid settings */
'message' => sprintf( _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', $invalid_setting_count ), number_format_i18n( $invalid_setting_count ) ), 'message' => sprintf( _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', $invalid_setting_count ), number_format_i18n( $invalid_setting_count ) ),
); );
return new WP_Error( 'transaction_fail', '', $response ); return new WP_Error( 'transaction_fail', '', $response );

View File

@ -710,7 +710,6 @@ final class WP_Customize_Widgets {
*/ */
$some_non_rendered_areas_messages = array(); $some_non_rendered_areas_messages = array();
$some_non_rendered_areas_messages[1] = html_entity_decode( $some_non_rendered_areas_messages[1] = html_entity_decode(
/* translators: placeholder is the number of other widget areas registered but not rendered */
__( 'Your theme has 1 other widget area, but this particular page doesn&#8217;t display it.' ), __( 'Your theme has 1 other widget area, but this particular page doesn&#8217;t display it.' ),
ENT_QUOTES, ENT_QUOTES,
get_bloginfo( 'charset' ) get_bloginfo( 'charset' )
@ -718,7 +717,7 @@ final class WP_Customize_Widgets {
$registered_sidebar_count = count( $wp_registered_sidebars ); $registered_sidebar_count = count( $wp_registered_sidebars );
for ( $non_rendered_count = 2; $non_rendered_count < $registered_sidebar_count; $non_rendered_count++ ) { for ( $non_rendered_count = 2; $non_rendered_count < $registered_sidebar_count; $non_rendered_count++ ) {
$some_non_rendered_areas_messages[ $non_rendered_count ] = html_entity_decode( sprintf( $some_non_rendered_areas_messages[ $non_rendered_count ] = html_entity_decode( sprintf(
/* translators: placeholder is the number of other widget areas registered but not rendered */ /* translators: %s: the number of other widget areas registered but not rendered */
_n( _n(
'Your theme has %s other widget area, but this particular page doesn&#8217;t display it.', 'Your theme has %s other widget area, but this particular page doesn&#8217;t display it.',
'Your theme has %s other widget areas, but this particular page doesn&#8217;t display them.', 'Your theme has %s other widget areas, but this particular page doesn&#8217;t display them.',
@ -730,12 +729,11 @@ final class WP_Customize_Widgets {
if ( 1 === $registered_sidebar_count ) { if ( 1 === $registered_sidebar_count ) {
$no_areas_shown_message = html_entity_decode( sprintf( $no_areas_shown_message = html_entity_decode( sprintf(
/* translators: placeholder is the total number of widget areas registered */
__( 'Your theme has 1 widget area, but this particular page doesn&#8217;t display it.' ) __( 'Your theme has 1 widget area, but this particular page doesn&#8217;t display it.' )
), ENT_QUOTES, get_bloginfo( 'charset' ) ); ), ENT_QUOTES, get_bloginfo( 'charset' ) );
} else { } else {
$no_areas_shown_message = html_entity_decode( sprintf( $no_areas_shown_message = html_entity_decode( sprintf(
/* translators: placeholder is the total number of widget areas registered */ /* translators: %s: the total number of widget areas registered */
_n( _n(
'Your theme has %s widget area, but this particular page doesn&#8217;t display it.', 'Your theme has %s widget area, but this particular page doesn&#8217;t display it.',
'Your theme has %s widget areas, but this particular page doesn&#8217;t display them.', 'Your theme has %s widget areas, but this particular page doesn&#8217;t display them.',
@ -763,7 +761,7 @@ final class WP_Customize_Widgets {
'reorderModeOn' => __( 'Reorder mode enabled' ), 'reorderModeOn' => __( 'Reorder mode enabled' ),
'reorderModeOff' => __( 'Reorder mode closed' ), 'reorderModeOff' => __( 'Reorder mode closed' ),
'reorderLabelOn' => esc_attr__( 'Reorder widgets' ), 'reorderLabelOn' => esc_attr__( 'Reorder widgets' ),
/* translators: placeholder is the count for the number of widgets found */ /* translators: %d: the number of widgets found */
'widgetsFound' => __( 'Number of widgets found: %d' ), 'widgetsFound' => __( 'Number of widgets found: %d' ),
'noWidgetsFound' => __( 'No widgets found.' ), 'noWidgetsFound' => __( 'No widgets found.' ),
), ),

View File

@ -473,7 +473,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'code-editor', "/wp-admin/js/code-editor$suffix.js", array( 'jquery', 'wp-codemirror' ) ); $scripts->add( 'code-editor', "/wp-admin/js/code-editor$suffix.js", array( 'jquery', 'wp-codemirror' ) );
$scripts->add( 'wp-theme-plugin-editor', "/wp-admin/js/theme-plugin-editor$suffix.js", array( 'code-editor', 'jquery', 'jquery-ui-core', 'wp-a11y', 'underscore' ) ); $scripts->add( 'wp-theme-plugin-editor', "/wp-admin/js/theme-plugin-editor$suffix.js", array( 'code-editor', 'jquery', 'jquery-ui-core', 'wp-a11y', 'underscore' ) );
did_action( 'init' ) && $scripts->add_inline_script( 'wp-theme-plugin-editor', sprintf( 'wp.themePluginEditor.l10n = %s;', wp_json_encode( wp_array_slice_assoc( did_action( 'init' ) && $scripts->add_inline_script( 'wp-theme-plugin-editor', sprintf( 'wp.themePluginEditor.l10n = %s;', wp_json_encode( wp_array_slice_assoc(
/* translators: placeholder is error count */ /* translators: %d: error count */
_n_noop( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.' ), _n_noop( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.' ),
array( 'singular', 'plural' ) array( 'singular', 'plural' )
) ) ) ); ) ) ) );
@ -571,19 +571,19 @@ function wp_default_scripts( &$scripts ) {
'expandSidebar' => _x( 'Show Controls', 'label for hide controls button without length constraints' ), 'expandSidebar' => _x( 'Show Controls', 'label for hide controls button without length constraints' ),
'untitledBlogName' => __( '(Untitled)' ), 'untitledBlogName' => __( '(Untitled)' ),
'serverSaveError' => __( 'Failed connecting to the server. Please try saving again.' ), 'serverSaveError' => __( 'Failed connecting to the server. Please try saving again.' ),
/* translators: placeholder is URL to the Customizer to load the autosaved version */ /* translators: %s: URL to the Customizer to load the autosaved version */
'autosaveNotice' => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ), 'autosaveNotice' => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ),
'videoHeaderNotice' => __( 'This theme doesn\'t support video headers on this page. Navigate to the front page or another page that supports video headers.' ), 'videoHeaderNotice' => __( 'This theme doesn\'t support video headers on this page. Navigate to the front page or another page that supports video headers.' ),
// Used for overriding the file types allowed in plupload. // Used for overriding the file types allowed in plupload.
'allowedFiles' => __( 'Allowed Files' ), 'allowedFiles' => __( 'Allowed Files' ),
'customCssError' => wp_array_slice_assoc( 'customCssError' => wp_array_slice_assoc(
/* translators: placeholder is error count */ /* translators: %d: error count */
_n_noop( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.' ), _n_noop( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.' ),
array( 'singular', 'plural' ) array( 'singular', 'plural' )
), ),
'pageOnFrontError' => __( 'Homepage and posts page must be different.' ), 'pageOnFrontError' => __( 'Homepage and posts page must be different.' ),
'saveBlockedError' => wp_array_slice_assoc( 'saveBlockedError' => wp_array_slice_assoc(
/* translators: placeholder is error count */ /* translators: %s: error count */
_n_noop( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.' ), _n_noop( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.' ),
array( 'singular', 'plural' ) array( 'singular', 'plural' )
), ),
@ -1170,7 +1170,7 @@ function wp_localize_community_events() {
'could_not_locate_city' => __( 'We couldn&#8217;t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ), 'could_not_locate_city' => __( 'We couldn&#8217;t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
// This one is only used with wp.a11y.speak(), so it can/should be more brief. // This one is only used with wp.a11y.speak(), so it can/should be more brief.
/* translators: %s is the name of a city. */ /* translators: %s: the name of a city */
'city_updated' => __( 'City updated. Listing events near %s.' ), 'city_updated' => __( 'City updated. Listing events near %s.' ),
) )
) ); ) );

View File

@ -176,7 +176,7 @@ class WP_Widget_Custom_HTML extends WP_Widget {
$l10n = array( $l10n = array(
'errorNotice' => wp_array_slice_assoc( 'errorNotice' => wp_array_slice_assoc(
/* translators: placeholder is error count */ /* translators: %d: error count */
_n_noop( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.' ), _n_noop( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.' ),
array( 'singular', 'plural' ) array( 'singular', 'plural' )
), ),

View File

@ -33,11 +33,11 @@ class WP_Widget_Media_Audio extends WP_Widget_Media {
'replace_media' => _x( 'Replace Audio', 'label for button in the audio widget; should preferably not be longer than ~13 characters long' ), 'replace_media' => _x( 'Replace Audio', 'label for button in the audio widget; should preferably not be longer than ~13 characters long' ),
'edit_media' => _x( 'Edit Audio', 'label for button in the audio widget; should preferably not be longer than ~13 characters long' ), 'edit_media' => _x( 'Edit Audio', 'label for button in the audio widget; should preferably not be longer than ~13 characters long' ),
'missing_attachment' => sprintf( 'missing_attachment' => sprintf(
/* translators: placeholder is URL to media library */ /* translators: %s: URL to media library */
__( 'We can&#8217;t find that audio file. Check your <a href="%s">media library</a> and make sure it wasn&#8217;t deleted.' ), __( 'We can&#8217;t find that audio file. Check your <a href="%s">media library</a> and make sure it wasn&#8217;t deleted.' ),
esc_url( admin_url( 'upload.php' ) ) esc_url( admin_url( 'upload.php' ) )
), ),
/* translators: %d is widget count */ /* translators: %d: widget count */
'media_library_state_multi' => _n_noop( 'Audio Widget (%d)', 'Audio Widget (%d)' ), 'media_library_state_multi' => _n_noop( 'Audio Widget (%d)', 'Audio Widget (%d)' ),
'media_library_state_single' => __( 'Audio Widget' ), 'media_library_state_single' => __( 'Audio Widget' ),
'unsupported_file_type' => __( 'Looks like this isn&#8217;t the correct kind of file. Please link to an audio file instead.' ), 'unsupported_file_type' => __( 'Looks like this isn&#8217;t the correct kind of file. Please link to an audio file instead.' ),
@ -77,7 +77,7 @@ class WP_Widget_Media_Audio extends WP_Widget_Media {
'type' => 'string', 'type' => 'string',
'default' => '', 'default' => '',
'format' => 'uri', 'format' => 'uri',
/* translators: placeholder is audio extension */ /* translators: %s: audio extension */
'description' => sprintf( __( 'URL to the %s audio source file' ), $audio_extension ), 'description' => sprintf( __( 'URL to the %s audio source file' ), $audio_extension ),
); );
} }

View File

@ -33,11 +33,11 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
'replace_media' => _x( 'Replace Image', 'label for button in the image widget; should preferably not be longer than ~13 characters long' ), 'replace_media' => _x( 'Replace Image', 'label for button in the image widget; should preferably not be longer than ~13 characters long' ),
'edit_media' => _x( 'Edit Image', 'label for button in the image widget; should preferably not be longer than ~13 characters long' ), 'edit_media' => _x( 'Edit Image', 'label for button in the image widget; should preferably not be longer than ~13 characters long' ),
'missing_attachment' => sprintf( 'missing_attachment' => sprintf(
/* translators: placeholder is URL to media library */ /* translators: %s: URL to media library */
__( 'We can&#8217;t find that image. Check your <a href="%s">media library</a> and make sure it wasn&#8217;t deleted.' ), __( 'We can&#8217;t find that image. Check your <a href="%s">media library</a> and make sure it wasn&#8217;t deleted.' ),
esc_url( admin_url( 'upload.php' ) ) esc_url( admin_url( 'upload.php' ) )
), ),
/* translators: %d is widget count */ /* translators: %d: widget count */
'media_library_state_multi' => _n_noop( 'Image Widget (%d)', 'Image Widget (%d)' ), 'media_library_state_multi' => _n_noop( 'Image Widget (%d)', 'Image Widget (%d)' ),
'media_library_state_single' => __( 'Image Widget' ), 'media_library_state_single' => __( 'Image Widget' ),
) ); ) );

View File

@ -33,15 +33,15 @@ class WP_Widget_Media_Video extends WP_Widget_Media {
'replace_media' => _x( 'Replace Video', 'label for button in the video widget; should preferably not be longer than ~13 characters long' ), 'replace_media' => _x( 'Replace Video', 'label for button in the video widget; should preferably not be longer than ~13 characters long' ),
'edit_media' => _x( 'Edit Video', 'label for button in the video widget; should preferably not be longer than ~13 characters long' ), 'edit_media' => _x( 'Edit Video', 'label for button in the video widget; should preferably not be longer than ~13 characters long' ),
'missing_attachment' => sprintf( 'missing_attachment' => sprintf(
/* translators: placeholder is URL to media library */ /* translators: %s: URL to media library */
__( 'We can&#8217;t find that video. Check your <a href="%s">media library</a> and make sure it wasn&#8217;t deleted.' ), __( 'We can&#8217;t find that video. Check your <a href="%s">media library</a> and make sure it wasn&#8217;t deleted.' ),
esc_url( admin_url( 'upload.php' ) ) esc_url( admin_url( 'upload.php' ) )
), ),
/* translators: %d is widget count */ /* translators: %d: widget count */
'media_library_state_multi' => _n_noop( 'Video Widget (%d)', 'Video Widget (%d)' ), 'media_library_state_multi' => _n_noop( 'Video Widget (%d)', 'Video Widget (%d)' ),
'media_library_state_single' => __( 'Video Widget' ), 'media_library_state_single' => __( 'Video Widget' ),
/* translators: placeholder is a list of valid video file extensions */ /* translators: %s: a list of valid video file extensions */
'unsupported_file_type' => sprintf( __( 'Sorry, we can&#8217;t display the video file type selected. Please select a supported video file (%1$s) or stream (YouTube or Vimeo) instead.' ), '<code>.' . implode( '</code>, <code>.', wp_get_video_extensions() ) . '</code>' ), 'unsupported_file_type' => sprintf( __( 'Sorry, we can&#8217;t display the video file type selected. Please select a supported video file (%s) or stream (YouTube or Vimeo) instead.' ), '<code>.' . implode( '</code>, <code>.', wp_get_video_extensions() ) . '</code>' ),
) ); ) );
} }
@ -87,7 +87,7 @@ class WP_Widget_Media_Video extends WP_Widget_Media {
'type' => 'string', 'type' => 'string',
'default' => '', 'default' => '',
'format' => 'uri', 'format' => 'uri',
/* translators: placeholder is video extension */ /* translators: %s: video extension */
'description' => sprintf( __( 'URL to the %s video source file' ), $video_extension ), 'description' => sprintf( __( 'URL to the %s video source file' ), $video_extension ),
); );
} }

View File

@ -69,11 +69,11 @@ abstract class WP_Widget_Media extends WP_Widget {
'edit_media' => _x( 'Edit Media', 'label for button in the media widget; should preferably not be longer than ~13 characters long' ), 'edit_media' => _x( 'Edit Media', 'label for button in the media widget; should preferably not be longer than ~13 characters long' ),
'add_to_widget' => __( 'Add to Widget' ), 'add_to_widget' => __( 'Add to Widget' ),
'missing_attachment' => sprintf( 'missing_attachment' => sprintf(
/* translators: placeholder is URL to media library */ /* translators: %s: URL to media library */
__( 'We can&#8217;t find that file. Check your <a href="%s">media library</a> and make sure it wasn&#8217;t deleted.' ), __( 'We can&#8217;t find that file. Check your <a href="%s">media library</a> and make sure it wasn&#8217;t deleted.' ),
esc_url( admin_url( 'upload.php' ) ) esc_url( admin_url( 'upload.php' ) )
), ),
/* translators: %d is widget count */ /* translators: %d: widget count */
'media_library_state_multi' => _n_noop( 'Media Widget (%d)', 'Media Widget (%d)' ), 'media_library_state_multi' => _n_noop( 'Media Widget (%d)', 'Media Widget (%d)' ),
'media_library_state_single' => __( 'Media Widget' ), 'media_library_state_single' => __( 'Media Widget' ),
'unsupported_file_type' => __( 'Looks like this isn&#8217;t the correct kind of file. Please link to an appropriate file instead.' ), 'unsupported_file_type' => __( 'Looks like this isn&#8217;t the correct kind of file. Please link to an appropriate file instead.' ),