Make WordPress Core

Changeset 48270


Ignore:
Timestamp:
07/01/2020 08:36:32 PM (5 years ago)
Author:
ocean90
Message:

I18N: Use wp.i18n for translatable strings in wp-admin/js/user-profile.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 #50527.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/user-profile.js

    r48121 r48270  
    33 */
    44
    5 /* global ajaxurl, pwsL10n, userProfileL10n */
     5/* global ajaxurl, pwsL10n */
    66(function($) {
    77    var updateLock = false,
    8 
     8        __ = wp.i18n.__,
    99        $pass1Row,
    1010        $pass1,
     
    4040
    4141        // Once zxcvbn loads, passwords strength is known.
    42         $( '#pw-weak-text-label' ).html( userProfileL10n.warnWeak );
     42        $( '#pw-weak-text-label' ).text( __( 'Confirm use of weak password' ) );
    4343    }
    4444
     
    6565        $toggleButton
    6666            .attr({
    67                 'aria-label': show ? userProfileL10n.ariaShow : userProfileL10n.ariaHide
     67                'aria-label': show ? __( 'Show password' ) : __( 'Hide password' )
    6868            })
    6969            .find( '.text' )
    70                 .text( show ? userProfileL10n.show : userProfileL10n.hide )
     70                .text( show ? __( 'Show' ) : __( 'Hide' ) )
    7171            .end()
    7272            .find( '.dashicons' )
     
    403403    $( window ).on( 'beforeunload', function () {
    404404        if ( true === updateLock ) {
    405             return userProfileL10n.warn;
     405            return __( 'Your new password has not been saved.' );
    406406        }
    407407    } );
  • trunk/src/wp-includes/script-loader.php

    r48268 r48270  
    10661066
    10671067    $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 );
    1068     did_action( 'init' ) && $scripts->localize(
    1069         'user-profile',
    1070         'userProfileL10n',
    1071         array(
    1072             'warn'     => __( 'Your new password has not been saved.' ),
    1073             'warnWeak' => __( 'Confirm use of weak password' ),
    1074             'show'     => __( 'Show' ),
    1075             'hide'     => __( 'Hide' ),
    1076             'cancel'   => __( 'Cancel' ),
    1077             'ariaShow' => esc_attr__( 'Show password' ),
    1078             'ariaHide' => esc_attr__( 'Hide password' ),
    1079         )
    1080     );
     1068    $scripts->set_translations( 'user-profile' );
    10811069
    10821070    $scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 );
Note: See TracChangeset for help on using the changeset viewer.