Make WordPress Core

Changeset 48274


Ignore:
Timestamp:
07/02/2020 11:09:23 AM (4 years ago)
Author:
SergeyBiryukov
Message:

I18N: Use wp.i18n for translatable strings in wp-admin/js/privacy-tools.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, afercia.
See #20491.
Fixes #50535.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/privacy-tools.js

    r48234 r48274  
    77// Privacy request action handling.
    88jQuery( document ).ready( function( $ ) {
    9     var strings = window.privacyToolsL10n || {},
     9    var __ = wp.i18n.__,
    1010        copiedNoticeTimeout;
    1111
     
    7878
    7979        function onExportDoneSuccess( zipUrl ) {
    80             var summaryMessage = strings.emailSent;
     80            var summaryMessage = __( 'The personal data export link for this user was sent.' );
    8181
    8282            setActionState( $action, 'export-personal-data-success' );
     
    8787                window.location = zipUrl;
    8888            } else if ( ! sendAsEmail ) {
    89                 onExportFailure( strings.noExportFile );
     89                onExportFailure( __( 'No personal data export file was generated.' ) );
    9090            }
    9191
     
    9494
    9595        function onExportFailure( errorMessage ) {
     96            var summaryMessage = __( 'An error occurred while attempting to export personal data.' );
     97
    9698            setActionState( $action, 'export-personal-data-failed' );
     99
    97100            if ( errorMessage ) {
    98                 appendResultsAfterRow( $requestRow, 'notice-error', strings.exportError, [ errorMessage ] );
     101                appendResultsAfterRow( $requestRow, 'notice-error', summaryMessage, [ errorMessage ] );
    99102            }
    100103
     
    176179
    177180        function onErasureDoneSuccess() {
    178             var summaryMessage = strings.noDataFound,
     181            var summaryMessage = __( 'No personal data was found for this user.' ),
    179182                classes = 'notice-success';
    180183
     
    183186            if ( false === hasRemoved ) {
    184187                if ( false === hasRetained ) {
    185                     summaryMessage = strings.noDataFound;
     188                    summaryMessage = __( 'No personal data was found for this user.' );
    186189                } else {
    187                     summaryMessage = strings.noneRemoved;
     190                    summaryMessage = __( 'Personal data was found for this user but was not erased.' );
    188191                    classes = 'notice-warning';
    189192                }
    190193            } else {
    191194                if ( false === hasRetained ) {
    192                     summaryMessage = strings.foundAndRemoved;
     195                    summaryMessage = __( 'All of the personal data found for this user was erased.' );
    193196                } else {
    194                     summaryMessage = strings.someNotRemoved;
     197                    summaryMessage = __( 'Personal data was found for this user but some of the personal data found was not erased.' );
    195198                    classes = 'notice-warning';
    196199                }
     
    202205
    203206        function onErasureFailure() {
     207            var summaryMessage = __( 'An error occurred while attempting to find and erase personal data.' );
     208
    204209            setActionState( $action, 'remove-personal-data-failed' );
    205             appendResultsAfterRow( $requestRow, 'notice-error', strings.removalError, [] );
     210
     211            appendResultsAfterRow( $requestRow, 'notice-error', summaryMessage, [] );
    206212
    207213            setTimeout( function() { $rowActions.removeClass( 'processing' ); }, 500 );
     
    268274            $container,
    269275            range,
    270             __ = wp.i18n.__,
    271276            $target = $( event.target ),
    272277            copiedNotice = $target.siblings( '.success' );
  • trunk/src/wp-includes/script-loader.php

    r48270 r48274  
    12061206    // To enqueue media-views or media-editor, call wp_enqueue_media().
    12071207    // Both rely on numerous settings, styles, and templates to operate correctly.
    1208     $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-api-request', 'wp-a11y', 'wp-i18n', 'clipboard' ), false, 1 );
     1208    $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-api-request', 'wp-a11y', 'clipboard' ), false, 1 );
    12091209    $scripts->set_translations( 'media-views' );
     1210
    12101211    $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
    12111212    $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
     
    13801381        );
    13811382
    1382         $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-i18n' ), false, 1 );
     1383        $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
    13831384        $scripts->set_translations( 'site-health' );
    13841385
    1385         $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y', 'wp-i18n' ), false, 1 );
    1386         did_action( 'init' ) && $scripts->localize(
    1387             'privacy-tools',
    1388             'privacyToolsL10n',
    1389             array(
    1390                 'noDataFound'     => __( 'No personal data was found for this user.' ),
    1391                 'foundAndRemoved' => __( 'All of the personal data found for this user was erased.' ),
    1392                 'noneRemoved'     => __( 'Personal data was found for this user but was not erased.' ),
    1393                 'someNotRemoved'  => __( 'Personal data was found for this user but some of the personal data found was not erased.' ),
    1394                 'removalError'    => __( 'An error occurred while attempting to find and erase personal data.' ),
    1395                 'emailSent'       => __( 'The personal data export link for this user was sent.' ),
    1396                 'noExportFile'    => __( 'No personal data export file was generated.' ),
    1397                 'exportError'     => __( 'An error occurred while attempting to export personal data.' ),
    1398             )
    1399         );
     1386        $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
     1387        $scripts->set_translations( 'privacy-tools' );
    14001388
    14011389        $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 );
Note: See TracChangeset for help on using the changeset viewer.