From f7357d395709bf0d779f66eeca8137b59b100796 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 2 Apr 2019 21:32:53 +0000 Subject: [PATCH] Site Health: i18n audit, take 1. * Split plural strings with multiple sentences to avoid duplicating translations. * Decouple strings where the singular and plural form are not just the same string with different numbers, but essentially two different strings. * Use an established pattern for numbered placeholders in translator comments. * Replace constants in translatable strings with placeholders, mark them as code. * Make sure sentences are translated as a whole, not as separate string parts. * Remove unnecessary context and escaping. Props ocean90, SergeyBiryukov. See #46683. Built from https://develop.svn.wordpress.org/trunk@45099 git-svn-id: http://core.svn.wordpress.org/trunk@44908 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../class-wp-site-health-auto-updates.php | 4 +- wp-admin/includes/class-wp-site-health.php | 232 ++++++++++-------- wp-admin/site-health-info.php | 2 +- wp-admin/site-health.php | 2 +- wp-includes/version.php | 2 +- 5 files changed, 130 insertions(+), 112 deletions(-) diff --git a/wp-admin/includes/class-wp-site-health-auto-updates.php b/wp-admin/includes/class-wp-site-health-auto-updates.php index 57511b3317..8e6ef9ac6a 100644 --- a/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -227,7 +227,7 @@ class WP_Site_Health_Auto_Updates { if ( $checkout && ! apply_filters( 'automatic_updates_is_vcs_checkout', true, ABSPATH ) ) { return array( 'description' => sprintf( - // translators: %1$s: Folder name. %2$s: Version control directory. %3$s: Filter name. + // translators: 1: Folder name. 2: Version control directory. 3: Filter name. __( 'The folder %1$s was detected as being under version control (%2$s), but the %3$s filter is allowing updates.' ), '' . $check_dir . '', "$vcs_dir", @@ -240,7 +240,7 @@ class WP_Site_Health_Auto_Updates { if ( $checkout ) { return array( 'description' => sprintf( - // translators: %1$s: Folder name. %2$s: Version control directory. + // translators: 1: Folder name. 2: Version control directory. __( 'The folder %1$s was detected as being under version control (%2$s).' ), '' . $check_dir . '', "$vcs_dir" diff --git a/wp-admin/includes/class-wp-site-health.php b/wp-admin/includes/class-wp-site-health.php index 56fa797c1a..f1717e957b 100644 --- a/wp-admin/includes/class-wp-site-health.php +++ b/wp-admin/includes/class-wp-site-health.php @@ -1,6 +1,6 @@ $plugin ) { @@ -311,13 +311,13 @@ class WP_Site_Health { $plugin_version = $plugin['Version']; if ( array_key_exists( $plugin_path, $plugin_updates ) ) { - $plugins_needs_update++; + $plugins_need_update++; $plugins_have_updates = true; } } // Add a notice if there are outdated plugins. - if ( $plugins_needs_update > 0 ) { + if ( $plugins_need_update > 0 ) { $result['status'] = 'critical'; $result['label'] = __( 'You have plugins waiting to be updated' ); @@ -325,32 +325,35 @@ class WP_Site_Health { $result['description'] .= sprintf( '

%s

', sprintf( - esc_html( - /* translators: %d: The number of outdated plugins. */ - _n( - 'Your site has %d plugin waiting to be updated.', - 'Your site has %d plugins waiting for updates.', - $plugins_needs_update - ) + /* translators: %d: The number of outdated plugins. */ + _n( + 'Your site has %d plugin waiting to be updated.', + 'Your site has %d plugins waiting to be updated.', + $plugins_need_update ), - $plugins_needs_update + $plugins_need_update ) ); } else { - $result['description'] .= sprintf( - '

%s

', - sprintf( - esc_html( + if ( 1 === $plugins_active ) { + $result['description'] .= sprintf( + '

%s

', + __( 'Your site has 1 active plugin, and it is up to date.' ) + ); + } else { + $result['description'] .= sprintf( + '

%s

', + sprintf( /* translators: %d: The number of active plugins. */ _n( - 'Your site has %d active plugin, and it is up to date.', + 'Your site has %d active plugin, and they are all up to date.', 'Your site has %d active plugins, and they are all up to date.', $plugins_active - ) - ), - $plugins_active - ) - ); + ), + $plugins_active + ) + ); + } } // Check if there are inactive plugins. @@ -362,18 +365,17 @@ class WP_Site_Health { $result['label'] = __( 'Inactive plugins should be removed' ); $result['description'] .= sprintf( - '

%s

', + '

%s %s

', sprintf( - esc_html( - /* translators: %d: The number of inactive plugins. */ - _n( - 'Your site has %d inactive plugin. Inactive plugins are tempting targets for attackers. if you’re not going to use a plugin, we recommend you remove it.', - 'Your site has %d inactive plugins. Inactive plugins are tempting targets for attackers. if you’re not going to use a plugin, we recommend you remove it.', - $unused_plugins - ) + /* translators: %d: The number of inactive plugins. */ + _n( + 'Your site has %d inactive plugin.', + 'Your site has %d inactive plugins.', + $unused_plugins ), $unused_plugins - ) + ), + __( 'Inactive plugins are tempting targets for attackers. If you’re not going to use a plugin, we recommend you remove it.' ) ); } @@ -464,33 +466,36 @@ class WP_Site_Health { $result['description'] .= sprintf( '

%s

', sprintf( - esc_html( - /* translators: %d: The number of outdated themes. */ - _n( - 'Your site has %d theme waiting to be updated.', - 'Your site has %d themes waiting to be updated.', - $themes_need_updates - ) + /* translators: %d: The number of outdated themes. */ + _n( + 'Your site has %d theme waiting to be updated.', + 'Your site has %d themes waiting to be updated.', + $themes_need_updates ), $themes_need_updates ) ); } else { // Give positive feedback about the site being good about keeping things up to date. - $result['description'] .= sprintf( - '

%s

', - sprintf( - esc_html( + if ( 1 === $themes_total ) { + $result['description'] .= sprintf( + '

%s

', + __( 'Your site has 1 installed theme, and it is up to date.' ) + ); + } else { + $result['description'] .= sprintf( + '

%s

', + sprintf( /* translators: %d: The number of themes. */ _n( - 'Your site has %d installed theme, and it is up to date.', + 'Your site has %d installed theme, and they are all up to date.', 'Your site has %d installed themes, and they are all up to date.', $themes_total - ) - ), - $themes_total - ) - ); + ), + $themes_total + ) + ); + } } if ( $has_unused_themes && $show_unused_themes ) { @@ -504,34 +509,38 @@ class WP_Site_Health { if ( $using_default_theme ) { $result['description'] .= sprintf( - '

%s

', + '

%s %s

', sprintf( - esc_html( - /* translators: %d: The number of inactive themes. */ - _n( - 'Your site has %1$d inactive theme. To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep your current theme, %2$s, and %3$s, its parent theme.', - 'Your site has %1$d inactive themes. To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep your current theme, %2$s, and %3$s, its parent theme.', - $themes_inactive - ) + /* translators: %d: The number of inactive themes. */ + _n( + 'Your site has %d inactive theme.', + 'Your site has %d inactive themes.', + $themes_inactive ), - $themes_inactive, + $themes_inactive + ), + sprintf( + /* translators: 1: The currently active theme. 2: The active theme's parent theme. */ + __( 'To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep your current theme, %1$s, and %2$s, its parent theme.' ), $active_theme->name, $active_theme->parent()->name ) ); } else { $result['description'] .= sprintf( - '

%s

', + '

%s %s

', sprintf( - esc_html( - /* translators: %1$d: The number of inactive themes. %2$s: The default theme for WordPress. %3$s: The currently active theme. %4$s: The active themes parent theme. */ - _n( - 'Your site has %1$d inactive theme. To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, its parent theme.', - 'Your site has %1$d inactive themes. To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, its parent theme.', - $themes_inactive - ) + /* translators: %d: The number of inactive themes. */ + _n( + 'Your site has %d inactive theme.', + 'Your site has %d inactive themes.', + $themes_inactive ), - $themes_inactive, + $themes_inactive + ), + sprintf( + /* translators: 1: The default theme for WordPress. 2: The currently active theme. 3: The active theme's parent theme. */ + __( 'To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep %1$s, the default WordPress theme, %2$s, your current theme, and %3$s, its parent theme.' ), WP_DEFAULT_THEME, $active_theme->name, $active_theme->parent()->name @@ -546,36 +555,34 @@ class WP_Site_Health { if ( $using_default_theme ) { $result['description'] .= sprintf( - '

%s

', + '

%s %s

', sprintf( - esc_html( - /* translators: %1$d: The amount of inactive themes. %2$s: The currently active theme. */ - _n( - 'Your site has %1$d inactive theme, other than %2$s, your active theme. We recommend removing any unused themes to enhance your sites security.', - 'Your site has %1$d inactive themes, other than %2$s, your active theme. We recommend removing any unused themes to enhance your sites security.', - $themes_inactive - ) + /* translators: 1: The amount of inactive themes. 2: The currently active theme. */ + _n( + 'Your site has %1$d inactive theme, other than %2$s, your active theme.', + 'Your site has %1$d inactive themes, other than %2$s, your active theme.', + $themes_inactive ), $themes_inactive, $active_theme->name - ) + ), + __( 'We recommend removing any unused themes to enhance your site’s security.' ) ); } else { $result['description'] .= sprintf( - '

%s

', + '

%s %s

', sprintf( - esc_html( - /* translators: %1$d: The amount of inactive themes. %2$s: The default theme for WordPress. %3$s: The currently active theme. */ - _n( - 'Your site has %1$d inactive theme, other than %2$s, the default WordPress theme, and %3$s, your active theme. We recommend removing any unused themes to enhance your sites security.', - 'Your site has %1$d inactive themes, other than %2$s, the default WordPress theme, and %3$s, your active theme. We recommend removing any unused themes to enhance your sites security.', - $themes_inactive - ) + /* translators: 1: The amount of inactive themes. 2: The default theme for WordPress. 3: The currently active theme. */ + _n( + 'Your site has %1$d inactive theme, other than %2$s, the default WordPress theme, and %3$s, your active theme.', + 'Your site has %1$d inactive themes, other than %2$s, the default WordPress theme, and %3$s, your active theme.', + $themes_inactive ), $themes_inactive, WP_DEFAULT_THEME, $active_theme->name - ) + ), + __( 'We recommend removing any unused themes to enhance your site’s security.' ) ); } } @@ -710,12 +717,9 @@ class WP_Site_Health { __( 'PHP modules perform most of the tasks on the server that make your site run.' ), sprintf( /* translators: %s: Link to the hosting group page about recommended PHP modules. */ - __( 'The Hosting team maintains a list of those modules, both recommended and required, in %s.' ), - sprintf( - '%s', - esc_url( _x( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions', 'The address to describe PHP modules and their use.' ) ), - __( 'the team handbook' ) - ) + __( 'The Hosting team maintains a list of those modules, both recommended and required, in the team handbook.' ), + /* translators: The address to describe PHP modules and their use. */ + esc_url( __( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions' ) ) ) ), 'actions' => '', @@ -922,7 +926,7 @@ class WP_Site_Health { $result['description'] .= sprintf( '

%s

', sprintf( - /* translators: %1$s: The database engine in use (MySQL or MariaDB). %2$s: Database server recommended version number. */ + /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server recommended version number. */ __( 'For optimal performance and security reasons, we recommend running %1$s version %2$s or higher. Contact your web hosting company to correct this.' ), ( $this->mariadb ? 'MariaDB' : 'MySQL' ), $this->health_check_mysql_rec_version @@ -938,7 +942,7 @@ class WP_Site_Health { $result['description'] .= sprintf( '

%s

', sprintf( - /* translators: %1$s: The database engine in use (MySQL or MariaDB). %2$s: Database server minimum version number. */ + /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server minimum version number. */ __( 'WordPress requires %1$s version %2$s or higher. Contact your web hosting company to correct this.' ), ( $this->mariadb ? 'MariaDB' : 'MySQL' ), $this->health_check_mysql_required_version @@ -951,8 +955,9 @@ class WP_Site_Health { '

%s

', wp_kses( sprintf( - /* translators: %s: The name of the database engine being used. */ - __( 'You are using a wp-content/db.php drop-in which might mean that a %s database is not being used.' ), + /* translators: 1: The name of the drop-in. 2: The name of the database engine. */ + __( 'You are using a %1$s drop-in which might mean that a %2$s database is not being used.' ), + 'wp-content/db.php', ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ) ), array( @@ -1054,7 +1059,7 @@ class WP_Site_Health { $result['description'] .= sprintf( '

%s

', sprintf( - /* translators: %1$s: Name of the library, %2$s: Number of version. */ + /* translators: 1: Name of the library, 2: Number of version. */ __( 'WordPress’ utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer.' ), 'mysqlnd', '5.0.9' @@ -1070,7 +1075,7 @@ class WP_Site_Health { $result['description'] .= sprintf( '

%s

', sprintf( - /* translators: %1$s: Name of the library, %2$s: Number of version. */ + /* translators: 1: Name of the library, 2: Number of version. */ __( 'WordPress’ utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer.' ), 'libmysql', '5.5.3' @@ -1124,7 +1129,7 @@ class WP_Site_Health { '%s %s', __( 'Error' ), sprintf( - /* translators: %1$s: The IP address WordPress.org resolves to. %2$s: The error returned by the lookup. */ + /* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */ __( 'Your site is unable to reach WordPress.org at %1$s, and returned the error: %2$s' ), gethostbyname( 'wordpress.org' ), $wp_dotorg->get_error_message() @@ -1173,7 +1178,11 @@ class WP_Site_Health { $result['description'] .= sprintf( '

%s

', - __( 'The value, WP_DEBUG_LOG, has been added to this websites configuration file. This means any errors on the site will be written to a file which is potentially available to normal users.' ) + sprintf( + /* translators: %s: Name of the constant used. */ + __( 'The value, %s, has been added to this website’s configuration file. This means any errors on the site will be written to a file which is potentially available to normal users.' ), + 'WP_DEBUG_LOG' + ) ); } @@ -1184,7 +1193,11 @@ class WP_Site_Health { $result['description'] .= sprintf( '

%s

', - __( 'The value, WP_DEBUG_DISPLAY, has either been added to your configuration file, or left with its default value. This will make errors display on the front end of your site.' ) + sprintf( + /* translators: %s: Name of the constant used. */ + __( 'The value, %s, has either been added to your configuration file, or left with its default value. This will make errors display on the front end of your site.' ), + 'WP_DEBUG_DISPLAY' + ) ); } } @@ -1217,7 +1230,7 @@ class WP_Site_Health { 'actions' => sprintf( '

%s

', esc_url( - /* translators: Website for explaining HTTPS and why it should be used. */ + /* translators: Documentation explaining HTTPS and why it should be used. */ __( 'https://wordpress.org/support/article/why-should-i-use-https/' ) ), __( 'Read more about why you should use HTTPS' ) @@ -1338,7 +1351,7 @@ class WP_Site_Health { '

%s

', sprintf( /* translators: %s: The error message returned while from the cron scheduler. */ - __( 'While trying to test your sites scheduled events, the following error was returned: %s' ), + __( 'While trying to test your site’s scheduled events, the following error was returned: %s' ), $this->has_missed_cron()->get_error_message() ) ); @@ -1524,7 +1537,11 @@ class WP_Site_Health { $result['description'] .= sprintf( '

%s

', - __( 'HTTP requests have been blocked by the WP_HTTP_BLOCK_EXTERNAL constant, with no allowed hosts.' ) + sprintf( + /* translators: %s: Name of the constant used. */ + __( 'HTTP requests have been blocked by the %s constant, with no allowed hosts.' ), + 'WP_HTTP_BLOCK_EXTERNAL' + ) ); } @@ -1536,8 +1553,9 @@ class WP_Site_Health { $result['description'] .= sprintf( '

%s

', sprintf( - /* translators: %s: List of hostnames whitelisted. */ - __( 'HTTP requests have been blocked by the WP_HTTP_BLOCK_EXTERNAL constant, with some hosts whitelisted: %s.' ), + /* translators: 1: Name of the constant used. 2: List of hostnames whitelisted. */ + __( 'HTTP requests have been blocked by the %1$s constant, with some hosts whitelisted: %2$s.' ), + 'WP_HTTP_BLOCK_EXTERNAL', implode( ',', $hosts ) ) ); @@ -1607,7 +1625,7 @@ class WP_Site_Health { '%s
%s', __( 'The REST API request failed due to an error.' ), sprintf( - /* translators: %1$d: The HTTP response code. %2$s: The error message returned. */ + /* translators: 1: The HTTP response code. 2: The error message returned. */ __( 'Error encountered: (%1$d) %2$s' ), wp_remote_retrieve_response_code( $r ), $r->get_error_message() @@ -1622,7 +1640,7 @@ class WP_Site_Health { $result['description'] .= sprintf( '

%s

', sprintf( - /* translators: %1$d: The HTTP response code returned. %2$s: The error message returned. */ + /* translators: 1: The HTTP response code returned. 2: The error message returned. */ __( 'The REST API call gave the following unexpected result: (%1$d) %2$s.' ), wp_remote_retrieve_response_code( $r ), wp_remote_retrieve_body( $r ) @@ -1888,7 +1906,7 @@ class WP_Site_Health { '%s
%s', __( 'The loopback request to your site failed, this means features relying on them are not currently working as expected.' ), sprintf( - // translators: %1$d: The HTTP response code. %2$s: The error message returned. + // translators: 1: The HTTP response code. 2: The error message returned. __( 'Error encountered: (%1$d) %2$s' ), wp_remote_retrieve_response_code( $r ), $r->get_error_message() diff --git a/wp-admin/site-health-info.php b/wp-admin/site-health-info.php index 06491c411a..abe178f366 100644 --- a/wp-admin/site-health-info.php +++ b/wp-admin/site-health-info.php @@ -32,7 +32,7 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );

- +

diff --git a/wp-admin/site-health.php b/wp-admin/site-health.php index 2a4fee18b5..cc4543e436 100644 --- a/wp-admin/site-health.php +++ b/wp-admin/site-health.php @@ -37,7 +37,7 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );

- +

diff --git a/wp-includes/version.php b/wp-includes/version.php index 4d52a6385e..0dd83bcee1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.2-beta1-45098'; +$wp_version = '5.2-beta1-45099'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.