Make WordPress Core

Ticket #42140: 42140.4.patch

File 42140.4.patch, 9.8 KB (added by poena, 4 years ago)

Moves the theme-count span and makes use of the data.count value

  • src/js/_enqueues/wp/customize/controls.js

     
    21192119                                                        }
    21202120                                                });
    21212121                                                if ( 'local' !== section.params.filter_type ) {
    2122                                                         wp.a11y.speak( api.settings.l10n.themeSearchResults.replace( '%d', data.info.results ) );
     2122                                                        wp.a11y.speak(
     2123                                                                wp.i18n.sprintf( wp.i18n._n( '%d theme found', '%d themes found', data.info.results ), data.info.results )
     2124                                                        );
    21232125                                                }
    21242126                                        }
    21252127
     
    24262428                 * @return {void}
    24272429                 */
    24282430                updateCount: function( count ) {
    2429                         var section = this, countEl, displayed;
     2431                        var section = this, i18n = wp.i18n, countEl, countText, displayed;
    24302432
    24312433                        if ( ! count && 0 !== count ) {
    24322434                                count = section.getVisibleCount();
     
    24342436
    24352437                        displayed = section.contentContainer.find( '.themes-displayed' );
    24362438                        countEl = section.contentContainer.find( '.theme-count' );
     2439                        countText = i18n.sprintf( i18n._n( '%s theme', '%s themes', count ), count );
    24372440
    24382441                        if ( 0 === count ) {
    2439                                 countEl.text( '0' );
     2442                                countEl.text( countText );
    24402443                        } else {
    24412444
    24422445                                // Animate the count change for emphasis.
    24432446                                displayed.fadeOut( 180, function() {
    2444                                         countEl.text( count );
     2447                                        countEl.text( countText );
    24452448                                        displayed.fadeIn( 180 );
    24462449                                } );
    2447                                 wp.a11y.speak( api.settings.l10n.announceThemeCount.replace( '%d', count ) );
     2450                                wp.a11y.speak(
     2451                                        i18n.sprintf( i18n._n( 'Displaying %d theme', 'Displaying %d themes', count ), count )
     2452                                );
    24482453                        }
    24492454                },
    24502455
     
    54885493                        control.setting.notifications.remove( 'csslint_error' );
    54895494
    54905495                        if ( 0 !== errorAnnotations.length ) {
    5491                                 if ( 1 === errorAnnotations.length ) {
    5492                                         message = api.l10n.customCssError.singular.replace( '%d', '1' );
    5493                                 } else {
    5494                                         message = api.l10n.customCssError.plural.replace( '%d', String( errorAnnotations.length ) );
    5495                                 }
     5496                                message = wp.i18n.sprintf(
     5497                                        wp.i18n._n(
     5498                                                'There is %d error which must be fixed before you can save.',
     5499                                                'There are %d errors which must be fixed before you can save.',
     5500                                                errorAnnotations.length
     5501                                        ),
     5502                                        errorAnnotations.length
     5503                                )
     5504
    54965505                                control.setting.notifications.add( new api.Notification( 'csslint_error', {
    54975506                                        message: message,
    54985507                                        type: 'error'
     
    75157524
    75167525                                                if ( invalidSettings.length ) {
    75177526                                                        api.notifications.add( new api.Notification( errorCode, {
    7518                                                                 message: ( 1 === invalidSettings.length ? api.l10n.saveBlockedError.singular : api.l10n.saveBlockedError.plural ).replace( /%s/g, String( invalidSettings.length ) ),
     7527                                                                message: wp.i18n.sprintf(
     7528                                                                        wp.i18n._n(
     7529                                                                                'Unable to save due to %s invalid setting.',
     7530                                                                                'Unable to save due to %s invalid settings.',
     7531                                                                                invalidSettings.length
     7532                                                                        ),
     7533                                                                        invalidSettings.length
     7534                                                                ),
    75197535                                                                type: 'error',
    75207536                                                                dismissible: true,
    75217537                                                                saveFailure: true
  • src/wp-includes/class-wp-customize-manager.php

     
    49014901                        'previewableDevices'     => $this->get_previewable_devices(),
    49024902                        'l10n'                   => array(
    49034903                                'confirmDeleteTheme'   => __( 'Are you sure you want to delete this theme?' ),
    4904                                 /* translators: %d: Number of theme search results, which cannot currently consider singular vs. plural forms. */
    4905                                 'themeSearchResults'   => __( '%d themes found' ),
    4906                                 /* translators: %d: Number of themes being displayed, which cannot currently consider singular vs. plural forms. */
    4907                                 'announceThemeCount'   => __( 'Displaying %d themes' ),
    49084904                                /* translators: %s: Theme name. */
    49094905                                'announceThemeDetails' => __( 'Showing details for theme: %s' ),
    49104906                        ),
    49114907                );
    49124908
     4909                // These strings are here for backwards compatibility; the translations now occur in JavaScript.
     4910                /* translators: %d: Number of theme search results. Note there is a newer translation of this string with singular and plural forms. */
     4911                $settings['l10n']['themeSearchResults'] = __( '%d themes found' );
     4912                /* translators: %d: Number of themes being displayed. Note there is a newer translation of this string with singular and plural forms. */
     4913                $settings['l10n']['announceThemeCount'] = __( 'Displaying %d themes' );
     4914
    49134915                // Temporarily disable installation in Customizer. See #42184.
    49144916                $filesystem_method = get_filesystem_method();
    49154917                ob_start();
  • src/wp-includes/customize/class-wp-customize-themes-section.php

     
    147147                <# } #>
    148148                <div class="filter-themes-count">
    149149                        <span class="themes-displayed">
     150                        <span class="theme-count">
    150151                                <?php
    151152                                /* translators: %s: Number of themes displayed. */
    152                                 printf( __( '%s themes' ), '<span class="theme-count">0</span>' );
     153                                printf( _n( '%s theme', '%s themes', '{{ data.count }}' ), '{{ data.count }}' );
    153154                                ?>
     155                                </span>
    154156                        </span>
    155157                </div>
    156158                <?php
  • src/wp-includes/script-loader.php

     
    11411141        $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'wp-a11y', 'customize-base' ), false, 1 );
    11421142        $scripts->add( 'customize-models', '/wp-includes/js/customize-models.js', array( 'underscore', 'backbone' ), false, 1 );
    11431143        $scripts->add( 'customize-views', '/wp-includes/js/customize-views.js', array( 'jquery', 'underscore', 'imgareaselect', 'customize-models', 'media-editor', 'media-views' ), false, 1 );
    1144         $scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base', 'wp-a11y', 'wp-util', 'jquery-ui-core' ), false, 1 );
     1144        $scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base', 'wp-a11y', 'wp-i18n', 'wp-util', 'jquery-ui-core' ), false, 1 );
    11451145        did_action( 'init' ) && $scripts->localize(
    11461146                'customize-controls',
    11471147                '_wpCustomizeControlsL10n',
     
    11841184                        'videoHeaderNotice'       => __( 'This theme doesn&#8217;t support video headers on this page. Navigate to the front page or another page that supports video headers.' ),
    11851185                        // Used for overriding the file types allowed in Plupload.
    11861186                        'allowedFiles'            => __( 'Allowed Files' ),
     1187                        'pageOnFrontError'        => __( 'Homepage and posts page must be different.' ),
     1188                        'scheduleDescription'     => __( 'Schedule your customization changes to publish ("go live") at a future date.' ),
     1189                        'themePreviewUnavailable' => __( 'Sorry, you can&#8217;t preview new themes when you have changes scheduled or saved as a draft. Please publish your changes, or wait until they publish to preview new themes.' ),
     1190                        'themeInstallUnavailable' => sprintf(
     1191                                /* translators: %s: URL to Add Themes admin screen. */
     1192                                __( 'You won&#8217;t be able to install new themes from here yet since your install requires SFTP credentials. For now, please <a href="%s">add themes in the admin</a>.' ),
     1193                                esc_url( admin_url( 'theme-install.php' ) )
     1194                        ),
     1195                        'publishSettings'         => __( 'Publish Settings' ),
     1196                        'invalidDate'             => __( 'Invalid date.' ),
     1197                        'invalidValue'            => __( 'Invalid value.' ),
     1198                        // These strings are here for backward compatibility; the translations now occurs in JavaScript.
    11871199                        'customCssError'          => array(
    11881200                                /* translators: %d: Error count. */
    11891201                                'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ),
    11901202                                /* translators: %d: Error count. */
    11911203                                'plural'   => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ),
    1192                                 // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
    11931204                        ),
    1194                         'pageOnFrontError'        => __( 'Homepage and posts page must be different.' ),
    11951205                        'saveBlockedError'        => array(
    11961206                                /* translators: %s: Number of invalid settings. */
    11971207                                'singular' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 1 ),
    11981208                                /* translators: %s: Number of invalid settings. */
    11991209                                'plural'   => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 2 ),
    1200                                 // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
    12011210                        ),
    1202                         'scheduleDescription'     => __( 'Schedule your customization changes to publish ("go live") at a future date.' ),
    1203                         'themePreviewUnavailable' => __( 'Sorry, you can&#8217;t preview new themes when you have changes scheduled or saved as a draft. Please publish your changes, or wait until they publish to preview new themes.' ),
    1204                         'themeInstallUnavailable' => sprintf(
    1205                                 /* translators: %s: URL to Add Themes admin screen. */
    1206                                 __( 'You won&#8217;t be able to install new themes from here yet since your install requires SFTP credentials. For now, please <a href="%s">add themes in the admin</a>.' ),
    1207                                 esc_url( admin_url( 'theme-install.php' ) )
    1208                         ),
    1209                         'publishSettings'         => __( 'Publish Settings' ),
    1210                         'invalidDate'             => __( 'Invalid date.' ),
    1211                         'invalidValue'            => __( 'Invalid value.' ),
    12121211                )
    12131212        );
    12141213        $scripts->add( 'customize-selective-refresh', "/wp-includes/js/customize-selective-refresh$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 );