From f4e1cf65c1f13a4ffb07e292e477890de5601afb Mon Sep 17 00:00:00 2001 From: jrf Date: Thu, 30 Aug 2018 13:36:25 +0000 Subject: [PATCH] I18n: Improve translators comments [3]. * Add missing translators comments. * Fix placement of some translators comments. Translators comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translators comments. Includes minor code layout fixes. Patch `44360-wp-admin-includes-dir.patch` of the series. Props flipkeijzer, alvarogois, michielatyoast See #44360 Built from https://develop.svn.wordpress.org/trunk@43598 git-svn-id: http://core.svn.wordpress.org/trunk@43427 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 21 +++++++++++-- wp-admin/includes/bookmark.php | 1 + .../class-bulk-plugin-upgrader-skin.php | 1 + .../class-bulk-theme-upgrader-skin.php | 1 + .../class-language-pack-upgrader-skin.php | 1 + .../includes/class-language-pack-upgrader.php | 2 +- .../includes/class-plugin-installer-skin.php | 1 + .../includes/class-theme-installer-skin.php | 12 ++++++-- .../includes/class-theme-upgrader-skin.php | 15 ++++++++-- wp-admin/includes/class-theme-upgrader.php | 6 ++-- .../class-walker-nav-menu-checklist.php | 1 + .../includes/class-walker-nav-menu-edit.php | 5 +++- .../includes/class-wp-automatic-updater.php | 30 ++++++++++++++++--- wp-includes/version.php | 2 +- 14 files changed, 81 insertions(+), 18 deletions(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index f3c54284a096..db22db292414 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -390,10 +390,12 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf( + /* translators: %s: number of comments approved */ _n( '%s Comment', '%s Comments', $counts->approved ), number_format_i18n( $counts->approved ) ), 'i18n_moderation_text' => sprintf( + /* translators: %s: number of comments in moderation */ _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ), number_format_i18n( $counts->moderated ) ), @@ -452,6 +454,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { 'supplemental' => array( 'status' => $comment ? $comment->comment_approved : '', 'postId' => $comment ? $comment->comment_post_ID : '', + /* translators: %s: number of comments */ 'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ), 'total_pages' => ceil( $total / $per_page ), 'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ), @@ -835,6 +838,7 @@ function wp_ajax_dim_comment() { $x = new WP_Ajax_Response( array( 'what' => 'comment', + /* translators: %d: comment ID */ 'id' => new WP_Error( 'invalid_comment', sprintf( __( 'Comment %d does not exist' ), $id ) ), ) ); @@ -1214,10 +1218,12 @@ function wp_ajax_replyto_comment( $action ) { $response['supplemental'] = array( 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf( + /* translators: %s: number of comments approved */ _n( '%s Comment', '%s Comments', $counts->approved ), number_format_i18n( $counts->approved ) ), 'i18n_moderation_text' => sprintf( + /* translators: %s: number of comments moderated */ _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ), number_format_i18n( $counts->moderated ) ), @@ -1813,7 +1819,15 @@ function wp_ajax_inline_save() { if ( $last = wp_check_post_lock( $post_ID ) ) { $last_user = get_userdata( $last ); $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); - printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), esc_html( $last_user_name ) ); + + /* translators: %s: user who is currently editing the post */ + $msg_template = __( 'Saving is disabled: %s is currently editing this post.' ); + if ( $_POST['post_type'] == 'page' ) { + /* translators: %s: user who is currently editing the page */ + $msg_template = __( 'Saving is disabled: %s is currently editing this page.' ); + } + + printf( $msg_template, esc_html( $last_user_name ) ); wp_die(); } @@ -2508,9 +2522,11 @@ function wp_ajax_wp_fullscreen_save_post() { } if ( $last_id = get_post_meta( $post_id, '_edit_last', true ) ) { - $last_user = get_userdata( $last_id ); + $last_user = get_userdata( $last_id ); + /* translators: 1: display_name of last user, 2: date of last edit, 3: time of last edit. */ $last_edited = sprintf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), $last_date, $last_time ); } else { + /* translators: 1: date of last edit, 2: time of last edit. */ $last_edited = sprintf( __( 'Last edited on %1$s at %2$s' ), $last_date, $last_time ); } @@ -3336,6 +3352,7 @@ function wp_ajax_parse_embed() { wp_send_json_error( array( 'type' => 'not-embeddable', + /* translators: %s: URL which cannot be embedded, between code tags */ 'message' => sprintf( __( '%s failed to embed.' ), '' . esc_html( $url ) . '' ), ) ); diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php index 5475d3d67f9c..fa425dda045b 100644 --- a/wp-admin/includes/bookmark.php +++ b/wp-admin/includes/bookmark.php @@ -319,6 +319,7 @@ function wp_link_manager_disabled_message() { if ( $really_can_manage_links && current_user_can( 'install_plugins' ) ) { $link = network_admin_url( 'plugin-install.php?tab=search&s=Link+Manager' ); + /* translators: %s: URL of link manager plugin */ wp_die( sprintf( __( 'If you are looking to use the link manager, please install the Link Manager plugin.' ), $link ) ); } diff --git a/wp-admin/includes/class-bulk-plugin-upgrader-skin.php b/wp-admin/includes/class-bulk-plugin-upgrader-skin.php index 4b407f76d602..a568d6b10713 100644 --- a/wp-admin/includes/class-bulk-plugin-upgrader-skin.php +++ b/wp-admin/includes/class-bulk-plugin-upgrader-skin.php @@ -20,6 +20,7 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin { public function add_strings() { parent::add_strings(); + /* translators: 1: name of plugin being updated, 2: number of updating plugin, 3: total number of plugins being updated */ $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)' ); } diff --git a/wp-admin/includes/class-bulk-theme-upgrader-skin.php b/wp-admin/includes/class-bulk-theme-upgrader-skin.php index 1ac8d3c6c543..ce426e015486 100644 --- a/wp-admin/includes/class-bulk-theme-upgrader-skin.php +++ b/wp-admin/includes/class-bulk-theme-upgrader-skin.php @@ -20,6 +20,7 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin { public function add_strings() { parent::add_strings(); + /* translators: 1: name of theme being updated, 2: number of updating themes, 3: total number of themes being updated */ $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Theme %1$s (%2$d/%3$d)' ); } diff --git a/wp-admin/includes/class-language-pack-upgrader-skin.php b/wp-admin/includes/class-language-pack-upgrader-skin.php index 3eb46cfd871e..1d59cc73cb75 100644 --- a/wp-admin/includes/class-language-pack-upgrader-skin.php +++ b/wp-admin/includes/class-language-pack-upgrader-skin.php @@ -47,6 +47,7 @@ public function before() { echo '
'; + /* translators: 1: name of project, 2: language */ printf( '

' . __( 'Updating translations for %1$s (%2$s)…' ) . '

', $name, $this->language_update->language ); } diff --git a/wp-admin/includes/class-language-pack-upgrader.php b/wp-admin/includes/class-language-pack-upgrader.php index 3982306aec16..aea15ef48e26 100644 --- a/wp-admin/includes/class-language-pack-upgrader.php +++ b/wp-admin/includes/class-language-pack-upgrader.php @@ -343,8 +343,8 @@ public function check_package( $source, $remote_source ) { return new WP_Error( 'incompatible_archive_pomo', $this->strings['incompatible_archive'], - /* translators: 1: .po, 2: .mo */ sprintf( + /* translators: 1: .po, 2: .mo */ __( 'The language pack is missing either the %1$s or %2$s files.' ), '.po', '.mo' diff --git a/wp-admin/includes/class-plugin-installer-skin.php b/wp-admin/includes/class-plugin-installer-skin.php index b4d25744514a..1d6dd0187659 100644 --- a/wp-admin/includes/class-plugin-installer-skin.php +++ b/wp-admin/includes/class-plugin-installer-skin.php @@ -42,6 +42,7 @@ public function __construct( $args = array() ) { */ public function before() { if ( ! empty( $this->api ) ) { + /* translators: 1: name of API, 2: version of API */ $this->upgrader->strings['process_success'] = sprintf( __( 'Successfully installed the plugin %1$s %2$s.' ), $this->api->name, $this->api->version ); } } diff --git a/wp-admin/includes/class-theme-installer-skin.php b/wp-admin/includes/class-theme-installer-skin.php index cf8ee0d88a7f..5f62e2c00bd9 100644 --- a/wp-admin/includes/class-theme-installer-skin.php +++ b/wp-admin/includes/class-theme-installer-skin.php @@ -75,16 +75,22 @@ public function after() { $install_actions = array(); if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { - $customize_url = add_query_arg( + $customize_url = add_query_arg( array( 'theme' => urlencode( $stylesheet ), 'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ), ), admin_url( 'customize.php' ) ); - $install_actions['preview'] = '' . sprintf( __( 'Live Preview “%s”' ), $name ) . ''; + $install_actions['preview'] = ''; + $install_actions['preview'] .= ''; + /* translators: %s: theme name */ + $install_actions['preview'] .= '' . sprintf( __( 'Live Preview “%s”' ), $name ) . ''; } - $install_actions['activate'] = '' . sprintf( __( 'Activate “%s”' ), $name ) . ''; + $install_actions['activate'] = ''; + $install_actions['activate'] .= ''; + /* translators: %s: theme name */ + $install_actions['activate'] .= '' . sprintf( __( 'Activate “%s”' ), $name ) . ''; if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) { $install_actions['network_enable'] = '' . __( 'Network Enable' ) . ''; diff --git a/wp-admin/includes/class-theme-upgrader-skin.php b/wp-admin/includes/class-theme-upgrader-skin.php index 395429620f73..062297df74e2 100644 --- a/wp-admin/includes/class-theme-upgrader-skin.php +++ b/wp-admin/includes/class-theme-upgrader-skin.php @@ -65,13 +65,22 @@ public function after() { ); if ( get_stylesheet() == $stylesheet ) { if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { - $update_actions['preview'] = '' . sprintf( __( 'Customize “%s”' ), $name ) . ''; + $update_actions['preview'] = ''; + $update_actions['preview'] .= ''; + /* translators: %s: theme name */ + $update_actions['preview'] .= '' . sprintf( __( 'Customize “%s”' ), $name ) . ''; } } elseif ( current_user_can( 'switch_themes' ) ) { if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { - $update_actions['preview'] = '' . sprintf( __( 'Live Preview “%s”' ), $name ) . ''; + $update_actions['preview'] = ''; + $update_actions['preview'] .= ''; + /* translators: %s: theme name */ + $update_actions['preview'] .= '' . sprintf( __( 'Live Preview “%s”' ), $name ) . ''; } - $update_actions['activate'] = '' . sprintf( __( 'Activate “%s”' ), $name ) . ''; + $update_actions['activate'] = ''; + $update_actions['activate'] .= ''; + /* translators: %s: theme name */ + $update_actions['activate'] .= '' . sprintf( __( 'Activate “%s”' ), $name ) . ''; } if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) { diff --git a/wp-admin/includes/class-theme-upgrader.php b/wp-admin/includes/class-theme-upgrader.php index eec26d5e0e30..7b521063f894 100644 --- a/wp-admin/includes/class-theme-upgrader.php +++ b/wp-admin/includes/class-theme-upgrader.php @@ -473,8 +473,8 @@ public function check_package( $source ) { return new WP_Error( 'incompatible_archive_theme_no_style', $this->strings['incompatible_archive'], - /* translators: %s: style.css */ sprintf( + /* translators: %s: style.css */ __( 'The theme is missing the %s stylesheet.' ), 'style.css' ) @@ -493,8 +493,8 @@ public function check_package( $source ) { return new WP_Error( 'incompatible_archive_theme_no_name', $this->strings['incompatible_archive'], - /* translators: %s: style.css */ sprintf( + /* translators: %s: style.css */ __( 'The %s stylesheet doesn’t contain a valid theme header.' ), 'style.css' ) @@ -506,8 +506,8 @@ public function check_package( $source ) { return new WP_Error( 'incompatible_archive_theme_no_index', $this->strings['incompatible_archive'], - /* translators: %s: index.php */ sprintf( + /* translators: %s: index.php */ __( 'The theme is missing the %s file.' ), 'index.php' ) diff --git a/wp-admin/includes/class-walker-nav-menu-checklist.php b/wp-admin/includes/class-walker-nav-menu-checklist.php index 881e9e71925b..994cc040f306 100644 --- a/wp-admin/includes/class-walker-nav-menu-checklist.php +++ b/wp-admin/includes/class-walker-nav-menu-checklist.php @@ -95,6 +95,7 @@ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 /** This filter is documented in wp-includes/post-template.php */ $title = apply_filters( 'the_title', $item->post_title, $item->ID ); if ( ! empty( $item->front_or_home ) && _x( 'Home', 'nav menu home label' ) !== $title ) { + /* translators: %s: front page title */ $title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $title ); } } diff --git a/wp-admin/includes/class-walker-nav-menu-edit.php b/wp-admin/includes/class-walker-nav-menu-edit.php index f1baecd6110a..eb940af37c1d 100644 --- a/wp-admin/includes/class-walker-nav-menu-edit.php +++ b/wp-admin/includes/class-walker-nav-menu-edit.php @@ -217,7 +217,10 @@ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0