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
This commit is contained in:
jrf 2018-08-30 13:36:25 +00:00
parent e1b0d4ed7a
commit f4e1cf65c1
14 changed files with 81 additions and 18 deletions

View File

@ -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.' ), '<code>' . esc_html( $url ) . '</code>' ),
)
);

View File

@ -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&amp;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 <a href="%s">Link Manager</a> plugin.' ), $link ) );
}

View File

@ -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)' );
}

View File

@ -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)' );
}

View File

@ -47,6 +47,7 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
echo '<div class="update-messages lp-show-latest">';
/* translators: 1: name of project, 2: language */
printf( '<h2>' . __( 'Updating translations for %1$s (%2$s)&#8230;' ) . '</h2>', $name, $this->language_update->language );
}

View File

@ -343,8 +343,8 @@ class Language_Pack_Upgrader extends WP_Upgrader {
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.' ),
'<code>.po</code>',
'<code>.mo</code>'

View File

@ -42,6 +42,7 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
*/
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 <strong>%1$s %2$s</strong>.' ), $this->api->name, $this->api->version );
}
}

View File

@ -75,16 +75,22 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
$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'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview &#8220;%s&#8221;' ), $name ) . '</span></a>';
$install_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize">';
$install_actions['preview'] .= '<span aria-hidden="true">' . __( 'Live Preview' ) . '</span>';
/* translators: %s: theme name */
$install_actions['preview'] .= '<span class="screen-reader-text">' . sprintf( __( 'Live Preview &#8220;%s&#8221;' ), $name ) . '</span></a>';
}
$install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate &#8220;%s&#8221;' ), $name ) . '</span></a>';
$install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink">';
$install_actions['activate'] .= '<span aria-hidden="true">' . __( 'Activate' ) . '</span>';
/* translators: %s: theme name */
$install_actions['activate'] .= '<span class="screen-reader-text">' . sprintf( __( 'Activate &#8220;%s&#8221;' ), $name ) . '</span></a>';
if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) {
$install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&amp;theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';

View File

@ -65,13 +65,22 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
);
if ( get_stylesheet() == $stylesheet ) {
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
$update_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Customize' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Customize &#8220;%s&#8221;' ), $name ) . '</span></a>';
$update_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize">';
$update_actions['preview'] .= '<span aria-hidden="true">' . __( 'Customize' ) . '</span>';
/* translators: %s: theme name */
$update_actions['preview'] .= '<span class="screen-reader-text">' . sprintf( __( 'Customize &#8220;%s&#8221;' ), $name ) . '</span></a>';
}
} elseif ( current_user_can( 'switch_themes' ) ) {
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
$update_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview &#8220;%s&#8221;' ), $name ) . '</span></a>';
$update_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize">';
$update_actions['preview'] .= '<span aria-hidden="true">' . __( 'Live Preview' ) . '</span>';
/* translators: %s: theme name */
$update_actions['preview'] .= '<span class="screen-reader-text">' . sprintf( __( 'Live Preview &#8220;%s&#8221;' ), $name ) . '</span></a>';
}
$update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate &#8220;%s&#8221;' ), $name ) . '</span></a>';
$update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink">';
$update_actions['activate'] .= '<span aria-hidden="true">' . __( 'Activate' ) . '</span>';
/* translators: %s: theme name */
$update_actions['activate'] .= '<span class="screen-reader-text">' . sprintf( __( 'Activate &#8220;%s&#8221;' ), $name ) . '</span></a>';
}
if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) {

View File

@ -473,8 +473,8 @@ class Theme_Upgrader extends WP_Upgrader {
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.' ),
'<code>style.css</code>'
)
@ -493,8 +493,8 @@ class Theme_Upgrader extends WP_Upgrader {
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&#8217;t contain a valid theme header.' ),
'<code>style.css</code>'
)
@ -506,8 +506,8 @@ class Theme_Upgrader extends WP_Upgrader {
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.' ),
'<code>index.php</code>'
)

View File

@ -95,6 +95,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
/** 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 );
}
}

View File

@ -217,7 +217,10 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
<div class="menu-item-actions description-wide submitbox">
<?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
<p class="link-to-original">
<?php printf( __( 'Original: %s' ), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
<?php
/* translators: %s: original title */
printf( __( 'Original: %s' ), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' );
?>
</p>
<?php endif; ?>
<a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="

View File

@ -307,24 +307,30 @@ class WP_Automatic_Updater {
$upgrader_item = $item;
switch ( $type ) {
case 'core':
/* translators: %s: WordPress version */
$skin->feedback( __( 'Updating to WordPress %s' ), $item->version );
/* translators: %s: WordPress version */
$item_name = sprintf( __( 'WordPress %s' ), $item->version );
break;
case 'theme':
$upgrader_item = $item->theme;
$theme = wp_get_theme( $upgrader_item );
$item_name = $theme->Get( 'Name' );
/* translators: %s: Theme name */
$skin->feedback( __( 'Updating theme: %s' ), $item_name );
break;
case 'plugin':
$upgrader_item = $item->plugin;
$plugin_data = get_plugin_data( $context . '/' . $upgrader_item );
$item_name = $plugin_data['Name'];
/* translators: %s: Plugin name */
$skin->feedback( __( 'Updating plugin: %s' ), $item_name );
break;
case 'translation':
$language_item_name = $upgrader->get_name_for_update( $item );
$item_name = sprintf( __( 'Translations for %s' ), $language_item_name );
/* translators: %s: Name of language item */
$item_name = sprintf( __( 'Translations for %s' ), $language_item_name );
/* translators: 1: Name of language item, 2: Language */
$skin->feedback( sprintf( __( 'Updating translations for %1$s (%2$s)&#8230;' ), $language_item_name, $item->language ) );
break;
}
@ -662,6 +668,7 @@ class WP_Automatic_Updater {
switch ( $type ) {
case 'success':
/* translators: 1: Home URL, 2: WordPress version */
$body .= sprintf( __( 'Howdy! Your site at %1$s has been updated automatically to WordPress %2$s.' ), home_url(), $core_update->current );
$body .= "\n\n";
if ( ! $newer_version_available ) {
@ -670,10 +677,12 @@ class WP_Automatic_Updater {
// Can only reference the About screen if their update was successful.
list( $about_version ) = explode( '-', $core_update->current, 2 );
$body .= sprintf( __( 'For more on version %s, see the About WordPress screen:' ), $about_version );
$body .= "\n" . admin_url( 'about.php' );
/* translators: %s: WordPress core version */
$body .= sprintf( __( 'For more on version %s, see the About WordPress screen:' ), $about_version );
$body .= "\n" . admin_url( 'about.php' );
if ( $newer_version_available ) {
/* translators: %s: WordPress core latest version */
$body .= "\n\n" . sprintf( __( 'WordPress %s is also now available.' ), $next_user_core_update->current ) . ' ';
$body .= __( 'Updating is easy and only takes a few moments:' );
$body .= "\n" . network_admin_url( 'update-core.php' );
@ -683,6 +692,7 @@ class WP_Automatic_Updater {
case 'fail':
case 'manual':
/* translators: 1: Home URL, 2: WordPress core latest version */
$body .= sprintf( __( 'Please update your site at %1$s to WordPress %2$s.' ), home_url(), $next_user_core_update->current );
$body .= "\n\n";
@ -699,8 +709,10 @@ class WP_Automatic_Updater {
case 'critical':
if ( $newer_version_available ) {
/* translators: 1: Home URL, 2: WordPress core latest version */
$body .= sprintf( __( 'Your site at %1$s experienced a critical failure while trying to update WordPress to version %2$s.' ), home_url(), $core_update->current );
} else {
/* translators: 1: Home URL, 2: Core update version */
$body .= sprintf( __( 'Your site at %1$s experienced a critical failure while trying to update to the latest version of WordPress, %2$s.' ), home_url(), $core_update->current );
}
@ -714,6 +726,7 @@ class WP_Automatic_Updater {
$critical_support = 'critical' === $type && ! empty( $core_update->support_email );
if ( $critical_support ) {
// Support offer if available.
/* translators: %s: Support e-mail */
$body .= "\n\n" . sprintf( __( 'The WordPress team is willing to help you. Forward this email to %s and the team will work with you to make sure your site is working.' ), $core_update->support_email );
} else {
// Add a note about the support forums.
@ -740,6 +753,7 @@ class WP_Automatic_Updater {
if ( 'critical' == $type && is_wp_error( $result ) ) {
$body .= "\n***\n\n";
/* translators: %s: WordPress version */
$body .= sprintf( __( 'Your site was running version %s.' ), get_bloginfo( 'version' ) );
$body .= ' ' . __( 'We have some data that describes the error your site encountered.' );
$body .= ' ' . __( 'Your hosting company, support forum volunteers, or a friendly developer may be able to use this information to help you:' );
@ -757,7 +771,8 @@ class WP_Automatic_Updater {
continue;
}
$error_code = $error->get_error_code();
$body .= "\n\n" . sprintf( __( 'Error code: %s' ), $error_code );
/* translators: %s: Error code */
$body .= "\n\n" . sprintf( __( 'Error code: %s' ), $error_code );
if ( 'rollback_was_required' == $error_code ) {
continue;
}
@ -815,14 +830,17 @@ class WP_Automatic_Updater {
$body = array();
$failures = 0;
/* translators: %s: Network home URL */
$body[] = sprintf( __( 'WordPress site: %s' ), network_home_url( '/' ) );
// Core
if ( isset( $this->update_results['core'] ) ) {
$result = $this->update_results['core'][0];
if ( $result->result && ! is_wp_error( $result->result ) ) {
/* translators: %s: WordPress core version */
$body[] = sprintf( __( 'SUCCESS: WordPress was successfully updated to %s' ), $result->name );
} else {
/* translators: %s: WordPress core version */
$body[] = sprintf( __( 'FAILED: WordPress failed to update to %s' ), $result->name );
$failures++;
}
@ -844,6 +862,7 @@ class WP_Automatic_Updater {
$body[] = $messages[ $type ];
foreach ( wp_list_pluck( $success_items, 'name' ) as $name ) {
/* translators: %s: name of plugin / theme / translations */
$body[] = ' * ' . sprintf( __( 'SUCCESS: %s' ), $name );
}
}
@ -858,6 +877,7 @@ class WP_Automatic_Updater {
$body[] = $messages[ $type ];
foreach ( $this->update_results[ $type ] as $item ) {
if ( ! $item->result || is_wp_error( $item->result ) ) {
/* translators: %s: name of plugin / theme / translations */
$body[] = ' * ' . sprintf( __( 'FAILED: %s' ), $item->name );
$failures++;
}
@ -884,8 +904,10 @@ Thanks! -- The WordPress Team"
);
$body[] = '';
/* translators: %s: site title */
$subject = sprintf( __( '[%s] There were failures during background updates' ), $site_title );
} else {
/* translators: %s: site title */
$subject = sprintf( __( '[%s] Background updates have finished' ), $site_title );
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-alpha-43597';
$wp_version = '5.0-alpha-43598';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.