From 13b5f8272a83ac60c82a4ae0e9f3ee12df3bda52 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 29 Sep 2017 11:41:06 +0000 Subject: [PATCH] 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 --- src/wp-admin/theme-editor.php | 2 +- src/wp-includes/class-wp-customize-manager.php | 2 +- src/wp-includes/class-wp-customize-widgets.php | 8 +++----- src/wp-includes/script-loader.php | 10 +++++----- .../widgets/class-wp-widget-custom-html.php | 2 +- .../widgets/class-wp-widget-media-audio.php | 6 +++--- .../widgets/class-wp-widget-media-image.php | 4 ++-- .../widgets/class-wp-widget-media-video.php | 10 +++++----- src/wp-includes/widgets/class-wp-widget-media.php | 4 ++-- 9 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index 35ec0402bc..2a593dee64 100644 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -35,7 +35,7 @@ get_current_screen()->add_help_tab( array( '' . '

' . __( 'After typing in your edits, click Update File.' ) . '

' . '

' . __( 'Advice: think very carefully about your site crashing if you are live-editing the theme currently in use.' ) . '

' . - /* translators: placeholder is link to codex article about child themes */ + /* translators: %s: link to codex article about child themes */ '

' . sprintf( __( 'Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a child theme instead.' ), __( 'https://codex.wordpress.org/Child_Themes' ) ) . '

' . ( is_network_admin() ? '

' . __( 'Any edits to files from this screen will be reflected on all sites in the network.' ) . '

' : '' ), ) ); diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index e81c92cc51..a9f07e1f1b 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -2616,7 +2616,7 @@ final class WP_Customize_Manager { if ( $update_transactionally && $invalid_setting_count > 0 ) { $response = array( '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 ) ), ); return new WP_Error( 'transaction_fail', '', $response ); diff --git a/src/wp-includes/class-wp-customize-widgets.php b/src/wp-includes/class-wp-customize-widgets.php index 973411b520..d723358173 100644 --- a/src/wp-includes/class-wp-customize-widgets.php +++ b/src/wp-includes/class-wp-customize-widgets.php @@ -710,7 +710,6 @@ final class WP_Customize_Widgets { */ $some_non_rendered_areas_messages = array(); $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’t display it.' ), ENT_QUOTES, get_bloginfo( 'charset' ) @@ -718,7 +717,7 @@ final class WP_Customize_Widgets { $registered_sidebar_count = count( $wp_registered_sidebars ); 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( - /* 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( 'Your theme has %s other widget area, but this particular page doesn’t display it.', 'Your theme has %s other widget areas, but this particular page doesn’t display them.', @@ -730,12 +729,11 @@ final class WP_Customize_Widgets { if ( 1 === $registered_sidebar_count ) { $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’t display it.' ) ), ENT_QUOTES, get_bloginfo( 'charset' ) ); } else { $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( 'Your theme has %s widget area, but this particular page doesn’t display it.', 'Your theme has %s widget areas, but this particular page doesn’t display them.', @@ -763,7 +761,7 @@ final class WP_Customize_Widgets { 'reorderModeOn' => __( 'Reorder mode enabled' ), 'reorderModeOff' => __( 'Reorder mode closed' ), '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' ), 'noWidgetsFound' => __( 'No widgets found.' ), ), diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index fb24c98274..7f6f6021d1 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -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( '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( - /* 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.' ), array( 'singular', 'plural' ) ) ) ) ); @@ -571,19 +571,19 @@ function wp_default_scripts( &$scripts ) { 'expandSidebar' => _x( 'Show Controls', 'label for hide controls button without length constraints' ), 'untitledBlogName' => __( '(Untitled)' ), '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. Restore the autosave' ), '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. 'allowedFiles' => __( 'Allowed Files' ), '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.' ), array( 'singular', 'plural' ) ), 'pageOnFrontError' => __( 'Homepage and posts page must be different.' ), '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.' ), array( 'singular', 'plural' ) ), @@ -1170,7 +1170,7 @@ function wp_localize_community_events() { 'could_not_locate_city' => __( 'We couldn’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. - /* translators: %s is the name of a city. */ + /* translators: %s: the name of a city */ 'city_updated' => __( 'City updated. Listing events near %s.' ), ) ) ); diff --git a/src/wp-includes/widgets/class-wp-widget-custom-html.php b/src/wp-includes/widgets/class-wp-widget-custom-html.php index 8c4e838e05..a75e264479 100644 --- a/src/wp-includes/widgets/class-wp-widget-custom-html.php +++ b/src/wp-includes/widgets/class-wp-widget-custom-html.php @@ -176,7 +176,7 @@ class WP_Widget_Custom_HTML extends WP_Widget { $l10n = array( '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.' ), array( 'singular', 'plural' ) ), diff --git a/src/wp-includes/widgets/class-wp-widget-media-audio.php b/src/wp-includes/widgets/class-wp-widget-media-audio.php index cfabe8c6a4..94d2295673 100644 --- a/src/wp-includes/widgets/class-wp-widget-media-audio.php +++ b/src/wp-includes/widgets/class-wp-widget-media-audio.php @@ -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' ), 'edit_media' => _x( 'Edit Audio', 'label for button in the audio widget; should preferably not be longer than ~13 characters long' ), 'missing_attachment' => sprintf( - /* translators: placeholder is URL to media library */ + /* translators: %s: URL to media library */ __( 'We can’t find that audio file. Check your media library and make sure it wasn’t deleted.' ), 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_single' => __( 'Audio Widget' ), 'unsupported_file_type' => __( 'Looks like this isn’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', 'default' => '', 'format' => 'uri', - /* translators: placeholder is audio extension */ + /* translators: %s: audio extension */ 'description' => sprintf( __( 'URL to the %s audio source file' ), $audio_extension ), ); } diff --git a/src/wp-includes/widgets/class-wp-widget-media-image.php b/src/wp-includes/widgets/class-wp-widget-media-image.php index 8fbb952f9a..bba1fb3f93 100644 --- a/src/wp-includes/widgets/class-wp-widget-media-image.php +++ b/src/wp-includes/widgets/class-wp-widget-media-image.php @@ -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' ), 'edit_media' => _x( 'Edit Image', 'label for button in the image widget; should preferably not be longer than ~13 characters long' ), 'missing_attachment' => sprintf( - /* translators: placeholder is URL to media library */ + /* translators: %s: URL to media library */ __( 'We can’t find that image. Check your media library and make sure it wasn’t deleted.' ), 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_single' => __( 'Image Widget' ), ) ); diff --git a/src/wp-includes/widgets/class-wp-widget-media-video.php b/src/wp-includes/widgets/class-wp-widget-media-video.php index 9fee44328b..5ba0526961 100644 --- a/src/wp-includes/widgets/class-wp-widget-media-video.php +++ b/src/wp-includes/widgets/class-wp-widget-media-video.php @@ -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' ), 'edit_media' => _x( 'Edit Video', 'label for button in the video widget; should preferably not be longer than ~13 characters long' ), 'missing_attachment' => sprintf( - /* translators: placeholder is URL to media library */ + /* translators: %s: URL to media library */ __( 'We can’t find that video. Check your media library and make sure it wasn’t deleted.' ), 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_single' => __( 'Video Widget' ), - /* translators: placeholder is a list of valid video file extensions */ - 'unsupported_file_type' => sprintf( __( 'Sorry, we can’t display the video file type selected. Please select a supported video file (%1$s) or stream (YouTube or Vimeo) instead.' ), '.' . implode( ', .', wp_get_video_extensions() ) . '' ), + /* translators: %s: a list of valid video file extensions */ + 'unsupported_file_type' => sprintf( __( 'Sorry, we can’t display the video file type selected. Please select a supported video file (%s) or stream (YouTube or Vimeo) instead.' ), '.' . implode( ', .', wp_get_video_extensions() ) . '' ), ) ); } @@ -87,7 +87,7 @@ class WP_Widget_Media_Video extends WP_Widget_Media { 'type' => 'string', 'default' => '', 'format' => 'uri', - /* translators: placeholder is video extension */ + /* translators: %s: video extension */ 'description' => sprintf( __( 'URL to the %s video source file' ), $video_extension ), ); } diff --git a/src/wp-includes/widgets/class-wp-widget-media.php b/src/wp-includes/widgets/class-wp-widget-media.php index 854cf885ae..58ad4647ac 100644 --- a/src/wp-includes/widgets/class-wp-widget-media.php +++ b/src/wp-includes/widgets/class-wp-widget-media.php @@ -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' ), 'add_to_widget' => __( 'Add to Widget' ), 'missing_attachment' => sprintf( - /* translators: placeholder is URL to media library */ + /* translators: %s: URL to media library */ __( 'We can’t find that file. Check your media library and make sure it wasn’t deleted.' ), 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_single' => __( 'Media Widget' ), 'unsupported_file_type' => __( 'Looks like this isn’t the correct kind of file. Please link to an appropriate file instead.' ),