Make WordPress Core


Ignore:
Timestamp:
07/07/2020 04:07:25 PM (4 years ago)
Author:
ocean90
Message:

I18N: Use wp.i18n for translatable strings in wp-admin/js/color-picker.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 #50596.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r48375 r48383  
    13501350        $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 );
    13511351        $scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 );
    1352         did_action( 'init' ) && $scripts->localize(
    1353             'wp-color-picker',
    1354             'wpColorPickerL10n',
    1355             array(
    1356                 'clear'            => __( 'Clear' ),
    1357                 'clearAriaLabel'   => __( 'Clear color' ),
    1358                 'defaultString'    => __( 'Default' ),
    1359                 'defaultAriaLabel' => __( 'Select default color' ),
    1360                 'pick'             => __( 'Select Color' ),
    1361                 'defaultLabel'     => __( 'Color value' ),
    1362             )
    1363         );
     1352        $scripts->set_translations( 'wp-color-picker' );
    13641353
    13651354        $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y' ), false, 1 );
Note: See TracChangeset for help on using the changeset viewer.