Make WordPress Core

Changeset 45099


Ignore:
Timestamp:
04/02/2019 09:31:43 PM (7 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/wp-admin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-site-health-auto-updates.php

    r45049 r45099  
    228228                        return array(
    229229                                'description' => sprintf(
    230                                         // translators: %1$s: Folder name. %2$s: Version control directory. %3$s: Filter name.
     230                                        // translators: 1: Folder name. 2: Version control directory. 3: Filter name.
    231231                                        __( 'The folder %1$s was detected as being under version control (%2$s), but the %3$s filter is allowing updates.' ),
    232232                                        '<code>' . $check_dir . '</code>',
     
    241241                        return array(
    242242                                'description' => sprintf(
    243                                         // translators: %1$s: Folder name. %2$s: Version control directory.
     243                                        // translators: 1: Folder name. 2: Version control directory.
    244244                                        __( 'The folder %1$s was detected as being under version control (%2$s).' ),
    245245                                        '<code>' . $check_dir . '</code>',
  • trunk/src/wp-admin/includes/class-wp-site-health.php

    r45095 r45099  
    11<?php
    22/**
    3  * Class for looking up a sites health based on a users WordPress environment.
     3 * Class for looking up a site's health based on a user's WordPress environment.
    44 *
    55 * @package WordPress
     
    299299                $plugins_active       = 0;
    300300                $plugins_total        = 0;
    301                 $plugins_needs_update = 0;
     301                $plugins_need_update = 0;
    302302
    303303                // Loop over the available plugins and check their versions and active state.
     
    312312
    313313                        if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
    314                                 $plugins_needs_update++;
     314                                $plugins_need_update++;
    315315                                $plugins_have_updates = true;
    316316                        }
     
    318318
    319319                // Add a notice if there are outdated plugins.
    320                 if ( $plugins_needs_update > 0 ) {
     320                if ( $plugins_need_update > 0 ) {
    321321                        $result['status'] = 'critical';
    322322
     
    326326                                '<p>%s</p>',
    327327                                sprintf(
    328                                         esc_html(
    329                                                 /* translators: %d: The number of outdated plugins. */
    330                                                 _n(
    331                                                         'Your site has %d plugin waiting to be updated.',
    332                                                         'Your site has %d plugins waiting for updates.',
    333                                                         $plugins_needs_update
    334                                                 )
     328                                        /* translators: %d: The number of outdated plugins. */
     329                                        _n(
     330                                                'Your site has %d plugin waiting to be updated.',
     331                                                'Your site has %d plugins waiting to be updated.',
     332                                                $plugins_need_update
    335333                                        ),
    336                                         $plugins_needs_update
     334                                        $plugins_need_update
    337335                                )
    338336                        );
    339337                } else {
    340                         $result['description'] .= sprintf(
    341                                 '<p>%s</p>',
    342                                 sprintf(
    343                                         esc_html(
     338                        if ( 1 === $plugins_active ) {
     339                                $result['description'] .= sprintf(
     340                                        '<p>%s</p>',
     341                                        __( 'Your site has 1 active plugin, and it is up to date.' )
     342                                );
     343                        } else {
     344                                $result['description'] .= sprintf(
     345                                        '<p>%s</p>',
     346                                        sprintf(
    344347                                                /* translators: %d: The number of active plugins. */
    345348                                                _n(
    346                                                         'Your site has %d active plugin, and it is up to date.',
     349                                                        'Your site has %d active plugin, and they are all up to date.',
    347350                                                        'Your site has %d active plugins, and they are all up to date.',
    348351                                                        $plugins_active
    349                                                 )
    350                                         ),
    351                                         $plugins_active
    352                                 )
    353                         );
     352                                                ),
     353                                                $plugins_active
     354                                        )
     355                                );
     356                        }
    354357                }
    355358
     
    363366
    364367                        $result['description'] .= sprintf(
    365                                 '<p>%s</p>',
     368                                '<p>%s %s</p>',
    366369                                sprintf(
    367                                         esc_html(
    368                                                 /* translators: %d: The number of inactive plugins. */
    369                                                 _n(
    370                                                         'Your site has %d inactive plugin. Inactive plugins are tempting targets for attackers. if you&#8217;re not going to use a plugin, we recommend you remove it.',
    371                                                         'Your site has %d inactive plugins. Inactive plugins are tempting targets for attackers. if you&#8217;re not going to use a plugin, we recommend you remove it.',
    372                                                         $unused_plugins
    373                                                 )
     370                                        /* translators: %d: The number of inactive plugins. */
     371                                        _n(
     372                                                'Your site has %d inactive plugin.',
     373                                                'Your site has %d inactive plugins.',
     374                                                $unused_plugins
    374375                                        ),
    375376                                        $unused_plugins
    376                                 )
     377                                ),
     378                                __( 'Inactive plugins are tempting targets for attackers. If you&#8217;re not going to use a plugin, we recommend you remove it.' )
    377379                        );
    378380                }
     
    465467                                '<p>%s</p>',
    466468                                sprintf(
    467                                         esc_html(
    468                                                 /* translators: %d: The number of outdated themes. */
    469                                                 _n(
    470                                                         'Your site has %d theme waiting to be updated.',
    471                                                         'Your site has %d themes waiting to be updated.',
    472                                                         $themes_need_updates
    473                                                 )
     469                                        /* translators: %d: The number of outdated themes. */
     470                                        _n(
     471                                                'Your site has %d theme waiting to be updated.',
     472                                                'Your site has %d themes waiting to be updated.',
     473                                                $themes_need_updates
    474474                                        ),
    475475                                        $themes_need_updates
     
    478478                } else {
    479479                        // Give positive feedback about the site being good about keeping things up to date.
    480                         $result['description'] .= sprintf(
    481                                 '<p>%s</p>',
    482                                 sprintf(
    483                                         esc_html(
     480                        if ( 1 === $themes_total ) {
     481                                $result['description'] .= sprintf(
     482                                        '<p>%s</p>',
     483                                        __( 'Your site has 1 installed theme, and it is up to date.' )
     484                                );
     485                        } else {
     486                                $result['description'] .= sprintf(
     487                                        '<p>%s</p>',
     488                                        sprintf(
    484489                                                /* translators: %d: The number of themes. */
    485490                                                _n(
    486                                                         'Your site has %d installed theme, and it is up to date.',
     491                                                        'Your site has %d installed theme, and they are all up to date.',
    487492                                                        'Your site has %d installed themes, and they are all up to date.',
    488493                                                        $themes_total
    489                                                 )
    490                                         ),
    491                                         $themes_total
    492                                 )
    493                         );
     494                                                ),
     495                                                $themes_total
     496                                        )
     497                                );
     498                        }
    494499                }
    495500
     
    505510                                if ( $using_default_theme ) {
    506511                                        $result['description'] .= sprintf(
    507                                                 '<p>%s</p>',
     512                                                '<p>%s %s</p>',
    508513                                                sprintf(
    509                                                         esc_html(
    510                                                                 /* translators: %d: The number of inactive themes. */
    511                                                                 _n(
    512                                                                         'Your site has %1$d inactive theme. To enhance your site&#8217;s security, we recommend you remove any themes you&#8217;re not using. You should keep your current theme, %2$s, and %3$s, its parent theme.',
    513                                                                         'Your site has %1$d inactive themes. To enhance your site&#8217;s security, we recommend you remove any themes you&#8217;re not using. You should keep your current theme, %2$s, and %3$s, its parent theme.',
    514                                                                         $themes_inactive
    515                                                                 )
     514                                                        /* translators: %d: The number of inactive themes. */
     515                                                        _n(
     516                                                                'Your site has %d inactive theme.',
     517                                                                'Your site has %d inactive themes.',
     518                                                                $themes_inactive
    516519                                                        ),
    517                                                         $themes_inactive,
     520                                                        $themes_inactive
     521                                                ),
     522                                                sprintf(
     523                                                        /* translators: 1: The currently active theme. 2: The active theme's parent theme. */
     524                                                        __( 'To enhance your site&#8217;s security, we recommend you remove any themes you&#8217;re not using. You should keep your current theme, %1$s, and %2$s, its parent theme.' ),
    518525                                                        $active_theme->name,
    519526                                                        $active_theme->parent()->name
     
    522529                                } else {
    523530                                        $result['description'] .= sprintf(
    524                                                 '<p>%s</p>',
     531                                                '<p>%s %s</p>',
    525532                                                sprintf(
    526                                                         esc_html(
    527                                                                 /* 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. */
    528                                                                 _n(
    529                                                                         'Your site has %1$d inactive theme. To enhance your site&#8217;s security, we recommend you remove any themes you&#8217;re not using. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, its parent theme.',
    530                                                                         'Your site has %1$d inactive themes. To enhance your site&#8217;s security, we recommend you remove any themes you&#8217;re not using. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, its parent theme.',
    531                                                                         $themes_inactive
    532                                                                 )
     533                                                        /* translators: %d: The number of inactive themes. */
     534                                                        _n(
     535                                                                'Your site has %d inactive theme.',
     536                                                                'Your site has %d inactive themes.',
     537                                                                $themes_inactive
    533538                                                        ),
    534                                                         $themes_inactive,
     539                                                        $themes_inactive
     540                                                ),
     541                                                sprintf(
     542                                                        /* translators: 1: The default theme for WordPress. 2: The currently active theme. 3: The active theme's parent theme. */
     543                                                        __( 'To enhance your site&#8217;s security, we recommend you remove any themes you&#8217;re not using. You should keep %1$s, the default WordPress theme, %2$s, your current theme, and %3$s, its parent theme.' ),
    535544                                                        WP_DEFAULT_THEME,
    536545                                                        $active_theme->name,
     
    547556                                if ( $using_default_theme ) {
    548557                                        $result['description'] .= sprintf(
    549                                                 '<p>%s</p>',
     558                                                '<p>%s %s</p>',
    550559                                                sprintf(
    551                                                         esc_html(
    552                                                                 /* translators: %1$d: The amount of inactive themes. %2$s: The currently active theme. */
    553                                                                 _n(
    554                                                                         '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.',
    555                                                                         '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.',
    556                                                                         $themes_inactive
    557                                                                 )
     560                                                        /* translators: 1: The amount of inactive themes. 2: The currently active theme. */
     561                                                        _n(
     562                                                                'Your site has %1$d inactive theme, other than %2$s, your active theme.',
     563                                                                'Your site has %1$d inactive themes, other than %2$s, your active theme.',
     564                                                                $themes_inactive
    558565                                                        ),
    559566                                                        $themes_inactive,
    560567                                                        $active_theme->name
    561                                                 )
     568                                                ),
     569                                                __( 'We recommend removing any unused themes to enhance your site&#8217;s security.' )
    562570                                        );
    563571                                } else {
    564572                                        $result['description'] .= sprintf(
    565                                                 '<p>%s</p>',
     573                                                '<p>%s %s</p>',
    566574                                                sprintf(
    567                                                         esc_html(
    568                                                                 /* translators: %1$d: The amount of inactive themes. %2$s: The default theme for WordPress. %3$s: The currently active theme. */
    569                                                                 _n(
    570                                                                         '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.',
    571                                                                         '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.',
    572                                                                         $themes_inactive
    573                                                                 )
     575                                                        /* translators: 1: The amount of inactive themes. 2: The default theme for WordPress. 3: The currently active theme. */
     576                                                        _n(
     577                                                                'Your site has %1$d inactive theme, other than %2$s, the default WordPress theme, and %3$s, your active theme.',
     578                                                                'Your site has %1$d inactive themes, other than %2$s, the default WordPress theme, and %3$s, your active theme.',
     579                                                                $themes_inactive
    574580                                                        ),
    575581                                                        $themes_inactive,
    576582                                                        WP_DEFAULT_THEME,
    577583                                                        $active_theme->name
    578                                                 )
     584                                                ),
     585                                                __( 'We recommend removing any unused themes to enhance your site&#8217;s security.' )
    579586                                        );
    580587                                }
     
    711718                                sprintf(
    712719                                        /* translators: %s: Link to the hosting group page about recommended PHP modules. */
    713                                         __( 'The Hosting team maintains a list of those modules, both recommended and required, in %s.' ),
    714                                         sprintf(
    715                                                 '<a href="%s">%s</a>',
    716                                                 esc_url( _x( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions', 'The address to describe PHP modules and their use.' ) ),
    717                                                 __( 'the team handbook' )
    718                                         )
     720                                        __( 'The Hosting team maintains a list of those modules, both recommended and required, in <a href="%s">the team handbook</a>.' ),
     721                                        /* translators: The address to describe PHP modules and their use. */
     722                                        esc_url( __( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions' ) )
    719723                                )
    720724                        ),
     
    923927                                '<p>%s</p>',
    924928                                sprintf(
    925                                         /* translators: %1$s: The database engine in use (MySQL or MariaDB). %2$s: Database server recommended version number. */
     929                                        /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server recommended version number. */
    926930                                        __( 'For optimal performance and security reasons, we recommend running %1$s version %2$s or higher. Contact your web hosting company to correct this.' ),
    927931                                        ( $this->mariadb ? 'MariaDB' : 'MySQL' ),
     
    939943                                '<p>%s</p>',
    940944                                sprintf(
    941                                         /* translators: %1$s: The database engine in use (MySQL or MariaDB). %2$s: Database server minimum version number. */
     945                                        /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server minimum version number. */
    942946                                        __( 'WordPress requires %1$s version %2$s or higher. Contact your web hosting company to correct this.' ),
    943947                                        ( $this->mariadb ? 'MariaDB' : 'MySQL' ),
     
    952956                                wp_kses(
    953957                                        sprintf(
    954                                                 /* translators: %s: The name of the database engine being used. */
    955                                                 __( 'You are using a <code>wp-content/db.php</code> drop-in which might mean that a %s database is not being used.' ),
     958                                                /* translators: 1: The name of the drop-in. 2: The name of the database engine. */
     959                                                __( 'You are using a %1$s drop-in which might mean that a %2$s database is not being used.' ),
     960                                                '<code>wp-content/db.php</code>',
    956961                                                ( $this->is_mariadb ? 'MariaDB' : 'MySQL' )
    957962                                        ),
     
    10551060                                        '<p>%s</p>',
    10561061                                        sprintf(
    1057                                                 /* translators: %1$s: Name of the library, %2$s: Number of version. */
     1062                                                /* translators: 1: Name of the library, 2: Number of version. */
    10581063                                                __( 'WordPress&#8217; utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer.' ),
    10591064                                                'mysqlnd',
     
    10711076                                        '<p>%s</p>',
    10721077                                        sprintf(
    1073                                                 /* translators: %1$s: Name of the library, %2$s: Number of version. */
     1078                                                /* translators: 1: Name of the library, 2: Number of version. */
    10741079                                                __( 'WordPress&#8217; utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer.' ),
    10751080                                                'libmysql',
     
    11251130                                        __( 'Error' ),
    11261131                                        sprintf(
    1127                                                 /* translators: %1$s: The IP address WordPress.org resolves to. %2$s: The error returned by the lookup. */
     1132                                                /* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */
    11281133                                                __( 'Your site is unable to reach WordPress.org at %1$s, and returned the error: %2$s' ),
    11291134                                                gethostbyname( 'wordpress.org' ),
     
    11741179                                $result['description'] .= sprintf(
    11751180                                        '<p>%s</p>',
    1176                                         __( '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.' )
     1181                                        sprintf(
     1182                                                /* translators: %s: Name of the constant used. */
     1183                                                __( 'The value, %s, has been added to this website&#8217;s configuration file. This means any errors on the site will be written to a file which is potentially available to normal users.' ),
     1184                                                '<code>WP_DEBUG_LOG</code>'
     1185                                        )
    11771186                                );
    11781187                        }
     
    11851194                                $result['description'] .= sprintf(
    11861195                                        '<p>%s</p>',
    1187                                         __( '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.' )
     1196                                        sprintf(
     1197                                                /* translators: %s: Name of the constant used. */
     1198                                                __( '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.' ),
     1199                                                '<code>WP_DEBUG_DISPLAY</code>'
     1200                                        )
    11881201                                );
    11891202                        }
     
    12181231                                '<p><a href="%s">%s</a></p>',
    12191232                                esc_url(
    1220                                         /* translators: Website for explaining HTTPS and why it should be used. */
     1233                                        /* translators: Documentation explaining HTTPS and why it should be used. */
    12211234                                        __( 'https://wordpress.org/support/article/why-should-i-use-https/' )
    12221235                                ),
     
    13391352                                sprintf(
    13401353                                        /* translators: %s: The error message returned while from the cron scheduler. */
    1341                                         __( 'While trying to test your sites scheduled events, the following error was returned: %s' ),
     1354                                        __( 'While trying to test your site&#8217;s scheduled events, the following error was returned: %s' ),
    13421355                                        $this->has_missed_cron()->get_error_message()
    13431356                                )
     
    15251538                        $result['description'] .= sprintf(
    15261539                                '<p>%s</p>',
    1527                                 __( 'HTTP requests have been blocked by the WP_HTTP_BLOCK_EXTERNAL constant, with no allowed hosts.' )
     1540                                sprintf(
     1541                                        /* translators: %s: Name of the constant used. */
     1542                                        __( 'HTTP requests have been blocked by the %s constant, with no allowed hosts.' ),
     1543                                        '<code>WP_HTTP_BLOCK_EXTERNAL</code>'
     1544                                )
    15281545                        );
    15291546                }
     
    15371554                                '<p>%s</p>',
    15381555                                sprintf(
    1539                                         /* translators: %s: List of hostnames whitelisted. */
    1540                                         __( 'HTTP requests have been blocked by the WP_HTTP_BLOCK_EXTERNAL constant, with some hosts whitelisted: %s.' ),
     1556                                        /* translators: 1: Name of the constant used. 2: List of hostnames whitelisted. */
     1557                                        __( 'HTTP requests have been blocked by the %1$s constant, with some hosts whitelisted: %2$s.' ),
     1558                                        '<code>WP_HTTP_BLOCK_EXTERNAL</code>',
    15411559                                        implode( ',', $hosts )
    15421560                                )
     
    16081626                                        __( 'The REST API request failed due to an error.' ),
    16091627                                        sprintf(
    1610                                                 /* translators: %1$d: The HTTP response code. %2$s: The error message returned. */
     1628                                                /* translators: 1: The HTTP response code. 2: The error message returned. */
    16111629                                                __( 'Error encountered: (%1$d) %2$s' ),
    16121630                                                wp_remote_retrieve_response_code( $r ),
     
    16231641                                '<p>%s</p>',
    16241642                                sprintf(
    1625                                         /* translators: %1$d: The HTTP response code returned. %2$s: The error message returned. */
     1643                                        /* translators: 1: The HTTP response code returned. 2: The error message returned. */
    16261644                                        __( 'The REST API call gave the following unexpected result: (%1$d) %2$s.' ),
    16271645                                        wp_remote_retrieve_response_code( $r ),
     
    18891907                                        __( 'The loopback request to your site failed, this means features relying on them are not currently working as expected.' ),
    18901908                                        sprintf(
    1891                                                 // translators: %1$d: The HTTP response code. %2$s: The error message returned.
     1909                                                // translators: 1: The HTTP response code. 2: The error message returned.
    18921910                                                __( 'Error encountered: (%1$d) %2$s' ),
    18931911                                                wp_remote_retrieve_response_code( $r ),
  • trunk/src/wp-admin/site-health-info.php

    r45091 r45099  
    3333        <div class="health-check-title-section">
    3434                <h1>
    35                         <?php _ex( 'Site Health', 'Menu, Section and Page Title' ); ?>
     35                        <?php _e( 'Site Health' ); ?>
    3636                </h1>
    3737
  • trunk/src/wp-admin/site-health.php

    r45091 r45099  
    3838        <div class="health-check-title-section">
    3939                <h1>
    40                         <?php _ex( 'Site Health', 'Menu, Section and Page Title' ); ?>
     40                        <?php _e( 'Site Health' ); ?>
    4141                </h1>
    4242
Note: See TracChangeset for help on using the changeset viewer.