Make WordPress Core

Changeset 47884


Ignore:
Timestamp:
06/01/2020 09:39:30 PM (5 years ago)
Author:
ocean90
Message:

I18N: Use wp.i18n for translatable strings in wp-admin/js/updates.js.

This removes the usage of wp_localize_script() for passing translations to the script and instead adds the translatable strings in the script directly through the use of wp.i18n and its utilities.

Props swissspidy, ocean90.
See #20491.
Fixes #50235.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/theme.js

    r47883 r47884  
    800800                $( document ).off( 'wp-auto-update-setting-changed', callback );
    801801            }
    802         }
     802        };
    803803
    804804        // Triggered in updates.js
  • trunk/src/js/_enqueues/wp/updates.js

    r47883 r47884  
    1313 * @param {object}  settings                            WP Updates settings.
    1414 * @param {string}  settings.ajax_nonce                 AJAX nonce.
    15  * @param {object}  settings.l10n                       Translation strings.
    1615 * @param {object=} settings.plugins                    Base names of plugins in their different states.
    1716 * @param {Array}   settings.plugins.all                Base names of all plugins.
     
    2827 */
    2928(function( $, wp, settings ) {
    30     var $document = $( document );
     29    var $document = $( document ),
     30        __ = wp.i18n.__,
     31        _x = wp.i18n._x,
     32        sprintf = wp.i18n.sprintf;
    3133
    3234    wp = wp || {};
     
    4951     */
    5052    wp.updates.ajaxNonce = settings.ajax_nonce;
    51 
    52     /**
    53      * Localized strings.
    54      *
    55      * @since 4.2.0
    56      *
    57      * @type {object}
    58      */
    59     wp.updates.l10n = settings.l10n;
    6053
    6154    /**
     
    382375            $updateRow = $( 'tr[data-plugin="' + args.plugin + '"]' );
    383376            $message   = $updateRow.find( '.update-message' ).removeClass( 'notice-error' ).addClass( 'updating-message notice-warning' ).find( 'p' );
    384             message    = wp.updates.l10n.pluginUpdatingLabel.replace( '%s', $updateRow.find( '.plugin-title strong' ).text() );
     377            message    = sprintf(
     378                /* translators: %s: Plugin name and version. */
     379                _x( 'Updating %s...', 'plugin' ),
     380                $updateRow.find( '.plugin-title strong' ).text()
     381            );
    385382        } else if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) {
    386383            $card    = $( '.plugin-card-' + args.slug );
    387384            $message = $card.find( '.update-now' ).addClass( 'updating-message' );
    388             message  = wp.updates.l10n.pluginUpdatingLabel.replace( '%s', $message.data( 'name' ) );
     385            message    = sprintf(
     386                /* translators: %s: Plugin name and version. */
     387                _x( 'Updating %s...', 'plugin' ),
     388                $message.data( 'name' )
     389            );
    389390
    390391            // Remove previous error messages, if any.
     
    392393        }
    393394
    394         if ( $message.html() !== wp.updates.l10n.updating ) {
     395        if ( $message.html() !== __( 'Updating...' ) ) {
    395396            $message.data( 'originaltext', $message.html() );
    396397        }
     
    398399        $message
    399400            .attr( 'aria-label', message )
    400             .text( wp.updates.l10n.updating );
     401            .text( __( 'Updating...' ) );
    401402
    402403        $document.trigger( 'wp-plugin-updating', args );
     
    443444
    444445        $updateMessage
    445             .attr( 'aria-label', wp.updates.l10n.pluginUpdatedLabel.replace( '%s', response.pluginName ) )
    446             .text( wp.updates.l10n.pluginUpdated );
    447 
    448         wp.a11y.speak( wp.updates.l10n.updatedMsg, 'polite' );
     446            .attr(
     447                'aria-label',
     448                sprintf(
     449                    /* translators: %s: Plugin name and version. */
     450                    _x( '%s updated!', 'plugin' ),
     451                    response.pluginName
     452                )
     453            )
     454            .text( _x( 'Updated!', 'plugin' ) );
     455
     456        wp.a11y.speak( __( 'Update completed successfully.' ), 'polite' );
    449457
    450458        wp.updates.decrementCount( 'plugin' );
     
    477485        }
    478486
    479         errorMessage = wp.updates.l10n.updateFailed.replace( '%s', response.errorMessage );
     487        errorMessage = sprintf(
     488            /* translators: %s: Error string for a failed update. */
     489            __( 'Update Failed: %s' ),
     490            response.errorMessage
     491        );
    480492
    481493        if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
     
    489501            if ( response.pluginName ) {
    490502                $message.find( 'p' )
    491                     .attr( 'aria-label', wp.updates.l10n.pluginUpdateFailedLabel.replace( '%s', response.pluginName ) );
     503                    .attr(
     504                        'aria-label',
     505                        sprintf(
     506                            /* translators: %s: Plugin name and version. */
     507                            _x( '%s update failed', 'plugin' ),
     508                            response.pluginName
     509                        )
     510                    );
    492511            } else {
    493512                $message.find( 'p' ).removeAttr( 'aria-label' );
     
    502521
    503522            $card.find( '.update-now' )
    504                 .text( wp.updates.l10n.updateFailedShort ).removeClass( 'updating-message' );
     523                .text(  __( 'Update Failed!' ) )
     524                .removeClass( 'updating-message' );
    505525
    506526            if ( response.pluginName ) {
    507527                $card.find( '.update-now' )
    508                     .attr( 'aria-label', wp.updates.l10n.pluginUpdateFailedLabel.replace( '%s', response.pluginName ) );
     528                    .attr(
     529                        'aria-label',
     530                        sprintf(
     531                            /* translators: %s: Plugin name and version. */
     532                            _x( '%s update failed', 'plugin' ),
     533                            response.pluginName
     534                        )
     535                    );
    509536            } else {
    510537                $card.find( '.update-now' ).removeAttr( 'aria-label' );
     
    521548                    $card.find( '.update-now' )
    522549                        .attr( 'aria-label', false )
    523                         .text( wp.updates.l10n.updateNow );
     550                        .text( __( 'Update Now' ) );
    524551                }, 200 );
    525552            } );
     
    556583        }
    557584
    558         if ( $message.html() !== wp.updates.l10n.installing ) {
     585        if ( $message.html() !== __( 'Installing...' ) ) {
    559586            $message.data( 'originaltext', $message.html() );
    560587        }
     
    562589        $message
    563590            .addClass( 'updating-message' )
    564             .attr( 'aria-label', wp.updates.l10n.pluginInstallingLabel.replace( '%s', $message.data( 'name' ) ) )
    565             .text( wp.updates.l10n.installing );
    566 
    567         wp.a11y.speak( wp.updates.l10n.installingMsg, 'polite' );
     591            .attr(
     592                'aria-label',
     593                sprintf(
     594                    /* translators: %s: Plugin name and version. */
     595                    _x( 'Installing %s...', 'plugin' ),
     596                    $message.data( 'name' )
     597                )
     598            )
     599            .text( __( 'Installing...' ) );
     600
     601        wp.a11y.speak( __( 'Installing... please wait.' ), 'polite' );
    568602
    569603        // Remove previous error messages, if any.
     
    591625            .removeClass( 'updating-message' )
    592626            .addClass( 'updated-message installed button-disabled' )
    593             .attr( 'aria-label', wp.updates.l10n.pluginInstalledLabel.replace( '%s', response.pluginName ) )
    594             .text( wp.updates.l10n.pluginInstalled );
    595 
    596         wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' );
     627            .attr(
     628                'aria-label',
     629                sprintf(
     630                    /* translators: %s: Plugin name and version. */
     631                    _x( '%s installed!', 'plugin' ),
     632                    response.pluginName
     633                )
     634            )
     635            .text( _x( 'Installed!', 'plugin' ) );
     636
     637        wp.a11y.speak( __( 'Installation completed successfully.' ), 'polite' );
    597638
    598639        $document.trigger( 'wp-plugin-install-success', response );
     
    602643
    603644                // Transform the 'Install' button into an 'Activate' button.
    604                 $message.removeClass( 'install-now installed button-disabled updated-message' ).addClass( 'activate-now button-primary' )
    605                     .attr( 'href', response.activateUrl )
    606                     .attr( 'aria-label', wp.updates.l10n.activatePluginLabel.replace( '%s', response.pluginName ) )
    607                     .text( wp.updates.l10n.activatePlugin );
     645                $message.removeClass( 'install-now installed button-disabled updated-message' )
     646                    .addClass( 'activate-now button-primary' )
     647                    .attr( 'href', response.activateUrl );
     648
     649                if ( 'plugins-network' === pagenow ) {
     650                    $message
     651                        .attr(
     652                            'aria-label',
     653                            sprintf(
     654                                /* translators: %s: Plugin name. */
     655                                _x( 'Network Activate %s', 'plugin' ),
     656                                response.pluginName
     657                            )
     658                        )
     659                        .text( __( 'Network Activate' ) );
     660                } else {
     661                    $message
     662                        .attr(
     663                            'aria-label',
     664                            sprintf(
     665                                /* translators: %s: Plugin name. */
     666                                _x( 'Activate %s', 'plugin' ),
     667                                response.pluginName
     668                            )
     669                        )
     670                        .text( __( 'Activate' ) );
     671                }
    608672            }, 1000 );
    609673        }
     
    634698        }
    635699
    636         errorMessage = wp.updates.l10n.installFailed.replace( '%s', response.errorMessage );
     700        errorMessage = sprintf(
     701            /* translators: %s: Error string for a failed installation. */
     702            __( 'Installation failed: %s' ),
     703            response.errorMessage
     704        );
    637705
    638706        $card
     
    652720        $button
    653721            .removeClass( 'updating-message' ).addClass( 'button-disabled' )
    654             .attr( 'aria-label', wp.updates.l10n.pluginInstallFailedLabel.replace( '%s', $button.data( 'name' ) ) )
    655             .text( wp.updates.l10n.installFailedShort );
     722            .attr(
     723                'aria-label',
     724                sprintf(
     725                    /* translators: %s: Plugin name and version. */
     726                    _x( '%s installation failed', 'plugin' ),
     727                    $button.data( 'name' )
     728                )
     729            )
     730            .text( __( 'Installation Failed!' ) );
    656731
    657732        wp.a11y.speak( errorMessage, 'assertive' );
     
    674749            id:        'install-success',
    675750            className: 'notice-success is-dismissible',
    676             message:   wp.updates.l10n.importerInstalledMsg.replace( '%s', response.activateUrl + '&from=import' )
     751            message:   sprintf(
     752                /* translators: %s: Activation URL. */
     753                __( 'Importer installed successfully. <a href="%s">Run importer</a>' ),
     754                response.activateUrl + '&from=import'
     755            )
    677756        } );
    678757
     
    682761            .attr({
    683762                'href': response.activateUrl + '&from=import',
    684                 'aria-label': wp.updates.l10n.activateImporterLabel.replace( '%s', response.pluginName )
     763                'aria-label':sprintf(
     764                    /* translators: %s: Importer name. */
     765                    __( 'Run %s' ),
     766                    response.pluginName
     767                )
    685768            })
    686             .text( wp.updates.l10n.activateImporter );
    687 
    688         wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' );
     769            .text( __( 'Run Importer' ) );
     770
     771        wp.a11y.speak( __( 'Installation completed successfully.' ), 'polite' );
    689772
    690773        $document.trigger( 'wp-importer-install-success', response );
     
    703786     */
    704787    wp.updates.installImporterError = function( response ) {
    705         var errorMessage = wp.updates.l10n.installFailed.replace( '%s', response.errorMessage ),
     788        var errorMessage = sprintf(
     789                /* translators: %s: Error string for a failed installation. */
     790                __( 'Installation failed: %s' ),
     791                response.errorMessage
     792            ),
    706793            $installLink = $( '[data-slug="' + response.slug + '"]' ),
    707794            pluginName = $installLink.data( 'name' );
     
    723810        $installLink
    724811            .removeClass( 'updating-message' )
    725             .text( wp.updates.l10n.installNow )
    726             .attr( 'aria-label', wp.updates.l10n.pluginInstallNowLabel.replace( '%s', pluginName ) );
     812            .attr(
     813                'aria-label',
     814                sprintf(
     815                    /* translators: %s: Plugin name. */
     816                     _x( 'Install %s now', 'plugin' ),
     817                     pluginName
     818                )
     819            )
     820            .text( __( 'Install Now' ) );
    727821
    728822        wp.a11y.speak( errorMessage, 'assertive' );
     
    752846        }, args );
    753847
    754         if ( $link.html() !== wp.updates.l10n.deleting ) {
     848        if ( $link.html() !== __( 'Deleting...' ) ) {
    755849            $link
    756850                .data( 'originaltext', $link.html() )
    757                 .text( wp.updates.l10n.deleting );
    758         }
    759 
    760         wp.a11y.speak( wp.updates.l10n.deleting, 'polite' );
     851                .text( __( 'Deleting...' ) );
     852        }
     853
     854        wp.a11y.speak( __( 'Deleting...' ), 'polite' );
    761855
    762856        $document.trigger( 'wp-plugin-deleting', args );
     
    848942
    849943                if ( ! $form.find( 'tr.no-items' ).length ) {
    850                     $form.find( '#the-list' ).append( '<tr class="no-items"><td class="colspanchange" colspan="' + columnCount + '">' + wp.updates.l10n.noPlugins + '</td></tr>' );
     944                    $form.find( '#the-list' ).append( '<tr class="no-items"><td class="colspanchange" colspan="' + columnCount + '">' + __( 'You do not appear to have any plugins available at this time.' ) + '</td></tr>' );
    851945                }
    852946            }
    853947        } );
    854948
    855         wp.a11y.speak( wp.updates.l10n.pluginDeleted, 'polite' );
     949        wp.a11y.speak( _x( 'Deleted!', 'plugin' ), 'polite' );
    856950
    857951        $document.trigger( 'wp-plugin-delete-success', response );
     
    9581052        }
    9591053
    960         if ( $notice.html() !== wp.updates.l10n.updating ) {
     1054        if ( $notice.html() !== __( 'Updating...' ) ) {
    9611055            $notice.data( 'originaltext', $notice.html() );
    9621056        }
    9631057
    964         wp.a11y.speak( wp.updates.l10n.updatingMsg, 'polite' );
    965         $notice.text( wp.updates.l10n.updating );
     1058        wp.a11y.speak( __( 'Updating... please wait.' ), 'polite' );
     1059        $notice.text( __( 'Updating...' ) );
    9661060
    9671061        $document.trigger( 'wp-theme-updating', args );
     
    9871081            updatedMessage = {
    9881082                className: 'updated-message notice-success notice-alt',
    989                 message:   wp.updates.l10n.themeUpdated
     1083                message:   _x( 'Updated!', 'theme' )
    9901084            },
    9911085            $notice, newText;
     
    10241118
    10251119        wp.updates.addAdminNotice( _.extend( { selector: $notice }, updatedMessage ) );
    1026         wp.a11y.speak( wp.updates.l10n.updatedMsg, 'polite' );
     1120        wp.a11y.speak( __( 'Update completed successfully.' ), 'polite' );
    10271121
    10281122        wp.updates.decrementCount( 'theme' );
     
    10481142    wp.updates.updateThemeError = function( response ) {
    10491143        var $theme       = $( '[data-slug="' + response.slug + '"]' ),
    1050             errorMessage = wp.updates.l10n.updateFailed.replace( '%s', response.errorMessage ),
     1144            errorMessage = sprintf(
     1145                /* translators: %s: Error string for a failed update. */
     1146                 __( 'Update Failed: %s' ),
     1147                response.errorMessage
     1148            ),
    10511149            $notice;
    10521150
     
    11041202        $message.addClass( 'updating-message' );
    11051203        $message.parents( '.theme' ).addClass( 'focus' );
    1106         if ( $message.html() !== wp.updates.l10n.installing ) {
     1204        if ( $message.html() !== __( 'Installing...' ) ) {
    11071205            $message.data( 'originaltext', $message.html() );
    11081206        }
    11091207
    11101208        $message
    1111             .text( wp.updates.l10n.installing )
    1112             .attr( 'aria-label', wp.updates.l10n.themeInstallingLabel.replace( '%s', $message.data( 'name' ) ) );
    1113         wp.a11y.speak( wp.updates.l10n.installingMsg, 'polite' );
     1209            .attr(
     1210                'aria-label',
     1211                sprintf(
     1212                    /* translators: %s: Theme name and version. */
     1213                    _x( 'Installing %s...', 'theme' ),
     1214                    $message.data( 'name' )
     1215                )
     1216            )
     1217            .text( __( 'Installing...' ) );
     1218
     1219        wp.a11y.speak( __( 'Installing... please wait.' ), 'polite' );
    11141220
    11151221        // Remove previous error messages, if any.
     
    11401246            .removeClass( 'updating-message' )
    11411247            .addClass( 'updated-message disabled' )
    1142             .attr( 'aria-label', wp.updates.l10n.themeInstalledLabel.replace( '%s', response.themeName ) )
    1143             .text( wp.updates.l10n.themeInstalled );
    1144 
    1145         wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' );
     1248            .attr(
     1249                'aria-label',
     1250                sprintf(
     1251                    /* translators: %s: Theme name and version. */
     1252                    _x( '%s installed!', 'theme' ),
     1253                    response.themeName
     1254                )
     1255            )
     1256            .text( _x( 'Installed!', 'theme' ) );
     1257
     1258        wp.a11y.speak( __( 'Installation completed successfully.' ), 'polite' );
    11461259
    11471260        setTimeout( function() {
     
    11531266                    .attr( 'href', response.activateUrl )
    11541267                    .removeClass( 'theme-install updated-message disabled' )
    1155                     .addClass( 'activate' )
    1156                     .attr( 'aria-label', wp.updates.l10n.activateThemeLabel.replace( '%s', response.themeName ) )
    1157                     .text( wp.updates.l10n.activateTheme );
     1268                    .addClass( 'activate' );
     1269
     1270                if ( 'themes-network' === pagenow ) {
     1271                    $message
     1272                        .attr(
     1273                            'aria-label',
     1274                            sprintf(
     1275                                /* translators: %s: Theme name. */
     1276                                _x( 'Network Activate %s', 'theme' ),
     1277                                response.themeName
     1278                            )
     1279                        )
     1280                        .text( __( 'Network Enable' ) );
     1281                } else {
     1282                    $message
     1283                        .attr(
     1284                            'aria-label',
     1285                            sprintf(
     1286                                /* translators: %s: Theme name. */
     1287                                _x( 'Activate %s', 'theme' ),
     1288                                response.themeName
     1289                            )
     1290                        )
     1291                        .text( __( 'Activate' ) );
     1292                }
    11581293            }
    11591294
     
    11651300                        .attr( 'href', response.customizeUrl )
    11661301                        .addClass( 'button load-customize' )
    1167                         .text( wp.updates.l10n.livePreview );
     1302                        .text( __( 'Live Preview' ) );
    11681303                } );
    11691304            }
     
    11831318    wp.updates.installThemeError = function( response ) {
    11841319        var $card, $button,
    1185             errorMessage = wp.updates.l10n.installFailed.replace( '%s', response.errorMessage ),
     1320            errorMessage = sprintf(
     1321                /* translators: %s: Error string for a failed installation. */
     1322                __( 'Installation failed: %s' ),
     1323                response.errorMessage
     1324            ),
    11861325            $message     = wp.updates.adminNotice( {
    11871326                className: 'update-message notice-error notice-alt',
     
    12181357        $button
    12191358            .removeClass( 'updating-message' )
    1220             .attr( 'aria-label', wp.updates.l10n.themeInstallFailedLabel.replace( '%s', $button.data( 'name' ) ) )
    1221             .text( wp.updates.l10n.installFailedShort );
     1359            .attr(
     1360                'aria-label',
     1361                sprintf(
     1362                    /* translators: %s: Theme name and version. */
     1363                    _x( '%s installation failed', 'theme' ),
     1364                    $button.data( 'name' )
     1365                )
     1366            )
     1367            .text( __( 'Installation Failed!' ) );
    12221368
    12231369        wp.a11y.speak( errorMessage, 'assertive' );
     
    12521398        }, args );
    12531399
    1254         if ( $button && $button.html() !== wp.updates.l10n.deleting ) {
     1400        if ( $button && $button.html() !== __( 'Deleting...' ) ) {
    12551401            $button
    12561402                .data( 'originaltext', $button.html() )
    1257                 .text( wp.updates.l10n.deleting );
    1258         }
    1259 
    1260         wp.a11y.speak( wp.updates.l10n.deleting, 'polite' );
     1403                .text( __( 'Deleting...' ) );
     1404        }
     1405
     1406        wp.a11y.speak( __( 'Deleting...' ), 'polite' );
    12611407
    12621408        // Remove previous error messages, if any.
     
    13211467        }
    13221468
    1323         wp.a11y.speak( wp.updates.l10n.themeDeleted, 'polite' );
     1469        wp.a11y.speak( _x( 'Deleted!', 'theme' ), 'polite' );
    13241470
    13251471        $document.trigger( 'wp-theme-delete-success', response );
     
    13411487            updateRow    = wp.template( 'item-update-row' ),
    13421488            $updateRow   = $themeRow.siblings( '#' + response.slug + '-update' ),
    1343             errorMessage = wp.updates.l10n.deleteFailed.replace( '%s', response.errorMessage ),
     1489            errorMessage = sprintf(
     1490                /* translators: %s: Error string for a failed deletion. */
     1491                __( 'Deletion failed: %s' ),
     1492                response.errorMessage
     1493            ),
    13441494            $message     = wp.updates.adminNotice( {
    13451495                className: 'update-message notice-error notice-alt',
     
    16321782     */
    16331783    wp.updates.isValidResponse = function( response, action ) {
    1634         var error = wp.updates.l10n.unknownError,
    1635             errorMessage;
     1784        var error = __( 'Something went wrong.' ),
     1785            errorMessage;
    16361786
    16371787        // Make sure the response is a valid data object and not a Promise object.
     
    16411791
    16421792        if ( _.isString( response ) && '-1' === response ) {
    1643             error = wp.updates.l10n.nonceError;
     1793            error = __( 'An error has occurred. Please reload the page and try again.' );
    16441794        } else if ( _.isString( response ) ) {
    16451795            error = response;
    16461796        } else if ( 'undefined' !== typeof response.readyState && 0 === response.readyState ) {
    1647             error = wp.updates.l10n.connectionError;
     1797            error = __( 'Connection lost or the server is busy. Please try again later.' );
    16481798        } else if ( _.isString( response.responseText ) && '' !== response.responseText ) {
    16491799            error = response.responseText;
     
    16541804        switch ( action ) {
    16551805            case 'update':
    1656                 errorMessage = wp.updates.l10n.updateFailed;
     1806                /* translators: %s: Error string for a failed update. */
     1807                errorMessage = __( 'Update Failed: %s' );
    16571808                break;
    16581809
    16591810            case 'install':
    1660                 errorMessage = wp.updates.l10n.installFailed;
     1811                /* translators: %s: Error string for a failed installation. */
     1812                errorMessage = __( 'Installation failed: %s' );
    16611813                break;
    16621814
    16631815            case 'delete':
    1664                 errorMessage = wp.updates.l10n.deleteFailed;
     1816                /* translators: %s: Error string for a failed deletion. */
     1817                errorMessage = __( 'Deletion failed: %s' );
    16651818                break;
    16661819        }
     
    16861839            .removeAttr( 'aria-label' )
    16871840            .prop( 'disabled', true )
    1688             .text( wp.updates.l10n.updateFailedShort );
     1841            .text( __( 'Update Failed!' ) );
    16891842
    16901843        $( '.updating-message:not(.button):not(.thickbox)' )
     
    17101863    wp.updates.beforeunload = function() {
    17111864        if ( wp.updates.ajaxLocked ) {
    1712             return wp.updates.l10n.beforeunload;
     1865            return __( 'Updates may not complete if you navigate away from this page.' );
    17131866        }
    17141867    };
     
    18231976                if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) {
    18241977                    if ( 'update-plugin' === job.action ) {
    1825                         $message.attr( 'aria-label', wp.updates.l10n.pluginUpdateNowLabel.replace( '%s', $message.data( 'name' ) ) );
     1978                        $message.attr(
     1979                            'aria-label',
     1980                            sprintf(
     1981                                /* translators: %s: Plugin name and version. */
     1982                                _x( 'Update %s now', 'plugin' ),
     1983                                $message.data( 'name' )
     1984                            )
     1985                        );
    18261986                    } else if ( 'install-plugin' === job.action ) {
    1827                         $message.attr( 'aria-label', wp.updates.l10n.pluginInstallNowLabel.replace( '%s', $message.data( 'name' ) ) );
     1987                        $message.attr(
     1988                            'aria-label',
     1989                            sprintf(
     1990                                /* translators: %s: Plugin name. */
     1991                                _x( 'Install %s now', 'plugin' ),
     1992                                $message.data( 'name' )
     1993                            )
     1994                        );
    18281995                    }
    18291996                }
    18301997            }
    18311998
    1832             wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
     1999            wp.a11y.speak( __( 'Update canceled.' ), 'polite' );
    18332000        } );
    18342001
     
    19062073                    $message
    19072074                        .removeClass( 'updating-message' )
    1908                         .text( wp.updates.l10n.installNow );
    1909 
    1910                     wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
     2075                        .text( __( 'Install Now' ) );
     2076
     2077                    wp.a11y.speak( __( 'Update canceled.' ), 'polite' );
    19112078                } );
    19122079            }
     
    19412108                    $button
    19422109                        .removeClass( 'updating-message' )
    1943                         .text( wp.updates.l10n.installNow )
    1944                         .attr( 'aria-label', wp.updates.l10n.pluginInstallNowLabel.replace( '%s', pluginName ) );
    1945 
    1946                     wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
     2110                        .attr(
     2111                            'aria-label',
     2112                            sprintf(
     2113                                /* translators: %s: Plugin name. */
     2114                                _x( 'Install %s now', 'plugin' ),
     2115                                pluginName
     2116                            )
     2117                        )
     2118                        .text( __( 'Install Now' ) );
     2119
     2120                    wp.a11y.speak( __( 'Update canceled.' ), 'polite' );
    19472121                } );
    19482122            }
     
    19642138         */
    19652139        $bulkActionForm.on( 'click', '[data-plugin] a.delete', function( event ) {
    1966             var $pluginRow = $( event.target ).parents( 'tr' );
     2140            var $pluginRow = $( event.target ).parents( 'tr' ),
     2141                confirmMessage = sprintf(
     2142                    /* translators: %s: Plugin name. */
     2143                    __( 'Are you sure you want to delete %s and its data?' ),
     2144                    $pluginRow.find( '.plugin-title strong' ).text()
     2145                );
    19672146
    19682147            event.preventDefault();
    19692148
    1970             if ( ! window.confirm( wp.updates.l10n.aysDeleteUninstall.replace( '%s', $pluginRow.find( '.plugin-title strong' ).text() ) ) ) {
     2149            if ( ! window.confirm( confirmMessage ) ) {
    19712150                return;
    19722151            }
     
    20152194         */
    20162195        $document.on( 'click', '.themes-php.network-admin a.delete', function( event ) {
    2017             var $themeRow = $( event.target ).parents( 'tr' );
     2196            var $themeRow = $( event.target ).parents( 'tr' ),
     2197                confirmMessage = sprintf(
     2198                    /* translators: %s: Theme name. */
     2199                    __( 'Are you sure you want to delete %s?' ),
     2200                    $themeRow.find( '.theme-title strong' ).text()
     2201                );
    20182202
    20192203            event.preventDefault();
    20202204
    2021             if ( ! window.confirm( wp.updates.l10n.aysDelete.replace( '%s', $themeRow.find( '.theme-title strong' ).text() ) ) ) {
     2205            if ( ! window.confirm( confirmMessage ) ) {
    20222206                return;
    20232207            }
     
    20702254                    id:        'no-items-selected',
    20712255                    className: 'notice-error is-dismissible',
    2072                     message:   wp.updates.l10n.noItemsSelected
     2256                    message:   __( 'Please select at least one item to perform this action on.' )
    20732257                } );
    20742258            }
     
    20812265
    20822266                case 'delete-selected':
    2083                     if ( ! window.confirm( 'plugin' === type ? wp.updates.l10n.aysBulkDelete : wp.updates.l10n.aysBulkDeleteThemes ) ) {
     2267                    var confirmMessage = 'plugin' === type ?
     2268                        __( 'Are you sure you want to delete the selected plugins and their data?' ) :
     2269                        __( 'Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?' );
     2270
     2271                    if ( ! window.confirm( confirmMessage ) ) {
    20842272                        event.preventDefault();
    20852273                        return;
     
    22182406                        'class': 'current',
    22192407                        'href': searchLocation,
    2220                         'text': wp.updates.l10n.searchResultsLabel
     2408                        'text': __( 'Search Results' )
    22212409                    } ) );
    22222410
     
    22412429
    22422430                if ( 0 === response.count ) {
    2243                     wp.a11y.speak( wp.updates.l10n.noPluginsFound );
     2431                    wp.a11y.speak( __( 'You do not appear to have any plugins available at this time.' ) );
    22442432                } else {
    2245                     wp.a11y.speak( wp.updates.l10n.pluginsFound.replace( '%d', response.count ) );
     2433                    wp.a11y.speak(
     2434                        sprintf(
     2435                            /* translators: %s: Number of plugins. */
     2436                            __( 'Number of plugins found: %d' ),
     2437                            response.count
     2438                        )
     2439                    );
    22462440                }
    22472441            } );
     
    22992493
    23002494                // Can we just ditch this whole subtitle business?
    2301                 var $subTitle    = $( '<span />' ).addClass( 'subtitle' ).html( wp.updates.l10n.searchResults.replace( '%s', _.escape( data.s ) ) ),
     2495                var $subTitle    = $( '<span />' ).addClass( 'subtitle' ).html(
     2496                    sprintf(
     2497                        /* translators: %s: Search query. */
     2498                        __( 'Search results for &#8220;%s&#8221;' ),
     2499                        _.escape( data.s )
     2500                    ) ),
    23022501                    $oldSubTitle = $( '.wrap .subtitle' );
    23032502
     
    23162515
    23172516                if ( 0 === response.count ) {
    2318                     wp.a11y.speak( wp.updates.l10n.noPluginsFound );
     2517                    wp.a11y.speak( __( 'No plugins found. Try a different search.'  ) );
    23192518                } else {
    2320                     wp.a11y.speak( wp.updates.l10n.pluginsFound.replace( '%d', response.count ) );
     2519                    wp.a11y.speak(
     2520                        sprintf(
     2521                            /* translators: %s: Number of plugins. */
     2522                            __( 'Number of plugins found: %d' ),
     2523                            response.count
     2524                        )
     2525                    );
    23212526                }
    23222527            } );
     
    25192724            // Show loading status.
    25202725            if ( 'enable' === action ) {
    2521                 $label.text( wp.updates.l10n.autoUpdatesEnabling );
     2726                $label.text( __( 'Enabling...' ) );
    25222727            } else {
    2523                 $label.text( wp.updates.l10n.autoUpdatesDisabling );
     2728                $label.text( __( 'Disabling...' ) );
    25242729            }
    25252730
     
    25452750                            errorMessage = response.data.error;
    25462751                        } else {
    2547                             errorMessage = wp.updates.l10n.autoUpdatesError;
     2752                            errorMessage = __( 'The request could not be completed.' );
    25482753                        }
    25492754
     
    25862791                        } );
    25872792
    2588                         $label.text( wp.updates.l10n.autoUpdatesDisable );
     2793                        $label.text( __( 'Disable auto-updates' ) );
    25892794                        $parent.find( '.auto-update-time' ).removeClass( 'hidden' );
    2590                         wp.a11y.speak( wp.updates.l10n.autoUpdatesEnabled, 'polite' );
     2795                        wp.a11y.speak( __( 'Enable auto-updates' ), 'polite' );
    25912796                    } else {
    25922797                        href = href.replace( 'action=disable-auto-update', 'action=enable-auto-update' );
     
    25962801                        } );
    25972802
    2598                         $label.text( wp.updates.l10n.autoUpdatesEnable );
     2803                        $label.text( __( 'Enable auto-updates' ) );
    25992804                        $parent.find( '.auto-update-time' ).addClass( 'hidden' );
    2600                         wp.a11y.speak( wp.updates.l10n.autoUpdatesDisabled, 'polite' );
     2805                        wp.a11y.speak( __( 'Auto-updates disabled' ), 'polite' );
    26012806                    }
    26022807
     
    26042809                } )
    26052810                .fail( function() {
    2606                     $parent.find( '.notice.error' ).removeClass( 'hidden' ).find( 'p' ).text( wp.updates.l10n.autoUpdatesError );
    2607                     wp.a11y.speak( wp.updates.l10n.autoUpdatesError, 'polite' );
     2811                    $parent.find( '.notice.error' )
     2812                        .removeClass( 'hidden' )
     2813                        .find( 'p' )
     2814                        .text( __( 'The request could not be completed.' ) );
     2815
     2816                    wp.a11y.speak( __( 'The request could not be completed.' ), 'polite' );
    26082817                } )
    26092818                .always( function() {
  • trunk/src/wp-includes/script-loader.php

    r47835 r47884  
    14351435
    14361436        $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 );
     1437        $scripts->set_translations( 'updates' );
    14371438        did_action( 'init' ) && $scripts->localize(
    14381439            'updates',
     
    14401441            array(
    14411442                'ajax_nonce' => wp_create_nonce( 'updates' ),
    1442                 'l10n'       => array(
    1443                     /* translators: %s: Search query. */
    1444                     'searchResults'            => __( 'Search results for &#8220;%s&#8221;' ),
    1445                     'searchResultsLabel'       => __( 'Search Results' ),
    1446                     'noPlugins'                => __( 'You do not appear to have any plugins available at this time.' ),
    1447                     'noItemsSelected'          => __( 'Please select at least one item to perform this action on.' ),
    1448                     'updating'                 => __( 'Updating...' ), // No ellipsis.
    1449                     'pluginUpdated'            => _x( 'Updated!', 'plugin' ),
    1450                     'themeUpdated'             => _x( 'Updated!', 'theme' ),
    1451                     'update'                   => __( 'Update' ),
    1452                     'updateNow'                => __( 'Update Now' ),
    1453                     /* translators: %s: Plugin name and version. */
    1454                     'pluginUpdateNowLabel'     => _x( 'Update %s now', 'plugin' ),
    1455                     'updateFailedShort'        => __( 'Update Failed!' ),
    1456                     /* translators: %s: Error string for a failed update. */
    1457                     'updateFailed'             => __( 'Update Failed: %s' ),
    1458                     /* translators: %s: Plugin name and version. */
    1459                     'pluginUpdatingLabel'      => _x( 'Updating %s...', 'plugin' ), // No ellipsis.
    1460                     /* translators: %s: Plugin name and version. */
    1461                     'pluginUpdatedLabel'       => _x( '%s updated!', 'plugin' ),
    1462                     /* translators: %s: Plugin name and version. */
    1463                     'pluginUpdateFailedLabel'  => _x( '%s update failed', 'plugin' ),
    1464                     /* translators: Accessibility text. */
    1465                     'updatingMsg'              => __( 'Updating... please wait.' ), // No ellipsis.
    1466                     /* translators: Accessibility text. */
    1467                     'updatedMsg'               => __( 'Update completed successfully.' ),
    1468                     /* translators: Accessibility text. */
    1469                     'updateCancel'             => __( 'Update canceled.' ),
    1470                     'beforeunload'             => __( 'Updates may not complete if you navigate away from this page.' ),
    1471                     'installNow'               => __( 'Install Now' ),
    1472                     /* translators: %s: Plugin name. */
    1473                     'pluginInstallNowLabel'    => _x( 'Install %s now', 'plugin' ),
    1474                     'installing'               => __( 'Installing...' ),
    1475                     'pluginInstalled'          => _x( 'Installed!', 'plugin' ),
    1476                     'themeInstalled'           => _x( 'Installed!', 'theme' ),
    1477                     'installFailedShort'       => __( 'Installation Failed!' ),
    1478                     /* translators: %s: Error string for a failed installation. */
    1479                     'installFailed'            => __( 'Installation failed: %s' ),
    1480                     /* translators: %s: Plugin name and version. */
    1481                     'pluginInstallingLabel'    => _x( 'Installing %s...', 'plugin' ), // No ellipsis.
    1482                     /* translators: %s: Theme name and version. */
    1483                     'themeInstallingLabel'     => _x( 'Installing %s...', 'theme' ), // No ellipsis.
    1484                     /* translators: %s: Plugin name and version. */
    1485                     'pluginInstalledLabel'     => _x( '%s installed!', 'plugin' ),
    1486                     /* translators: %s: Theme name and version. */
    1487                     'themeInstalledLabel'      => _x( '%s installed!', 'theme' ),
    1488                     /* translators: %s: Plugin name and version. */
    1489                     'pluginInstallFailedLabel' => _x( '%s installation failed', 'plugin' ),
    1490                     /* translators: %s: Theme name and version. */
    1491                     'themeInstallFailedLabel'  => _x( '%s installation failed', 'theme' ),
    1492                     'installingMsg'            => __( 'Installing... please wait.' ),
    1493                     'installedMsg'             => __( 'Installation completed successfully.' ),
    1494                     /* translators: %s: Activation URL. */
    1495                     'importerInstalledMsg'     => __( 'Importer installed successfully. <a href="%s">Run importer</a>' ),
    1496                     /* translators: %s: Theme name. */
    1497                     'aysDelete'                => __( 'Are you sure you want to delete %s?' ),
    1498                     /* translators: %s: Plugin name. */
    1499                     'aysDeleteUninstall'       => __( 'Are you sure you want to delete %s and its data?' ),
    1500                     'aysBulkDelete'            => __( 'Are you sure you want to delete the selected plugins and their data?' ),
    1501                     'aysBulkDeleteThemes'      => __( 'Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?' ),
    1502                     'deleting'                 => __( 'Deleting...' ),
    1503                     /* translators: %s: Error string for a failed deletion. */
    1504                     'deleteFailed'             => __( 'Deletion failed: %s' ),
    1505                     'pluginDeleted'            => _x( 'Deleted!', 'plugin' ),
    1506                     'themeDeleted'             => _x( 'Deleted!', 'theme' ),
    1507                     'livePreview'              => __( 'Live Preview' ),
    1508                     'activatePlugin'           => is_network_admin() ? __( 'Network Activate' ) : __( 'Activate' ),
    1509                     'activateTheme'            => is_network_admin() ? __( 'Network Enable' ) : __( 'Activate' ),
    1510                     /* translators: %s: Plugin name. */
    1511                     'activatePluginLabel'      => is_network_admin() ? _x( 'Network Activate %s', 'plugin' ) : _x( 'Activate %s', 'plugin' ),
    1512                     /* translators: %s: Theme name. */
    1513                     'activateThemeLabel'       => is_network_admin() ? _x( 'Network Activate %s', 'theme' ) : _x( 'Activate %s', 'theme' ),
    1514                     'activateImporter'         => __( 'Run Importer' ),
    1515                     /* translators: %s: Importer name. */
    1516                     'activateImporterLabel'    => __( 'Run %s' ),
    1517                     'unknownError'             => __( 'Something went wrong.' ),
    1518                     'connectionError'          => __( 'Connection lost or the server is busy. Please try again later.' ),
    1519                     'nonceError'               => __( 'An error has occurred. Please reload the page and try again.' ),
    1520                     /* translators: %s: Number of plugins. */
    1521                     'pluginsFound'             => __( 'Number of plugins found: %d' ),
    1522                     'noPluginsFound'           => __( 'No plugins found. Try a different search.' ),
    1523                     'autoUpdatesEnable'        => __( 'Enable auto-updates' ),
    1524                     'autoUpdatesEnabling'      => __( 'Enabling...' ),
    1525                     'autoUpdatesEnabled'       => __( 'Auto-updates enabled' ),
    1526                     'autoUpdatesDisable'       => __( 'Disable auto-updates' ),
    1527                     'autoUpdatesDisabling'     => __( 'Disabling...' ),
    1528                     'autoUpdatesDisabled'      => __( 'Auto-updates disabled' ),
    1529                     'autoUpdatesError'         => __( 'The request could not be completed.' ),
    1530                 ),
    15311443            )
    15321444        );
Note: See TracChangeset for help on using the changeset viewer.