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. git-svn-id: https://develop.svn.wordpress.org/trunk@48383 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e16565b2d4
commit
e39812fe53
@ -2,7 +2,6 @@
|
||||
* @output wp-admin/js/color-picker.js
|
||||
*/
|
||||
|
||||
/* global wpColorPickerL10n */
|
||||
( function( $, undef ) {
|
||||
|
||||
var ColorPicker,
|
||||
@ -11,7 +10,8 @@
|
||||
_wrap = '<div class="wp-picker-container" />',
|
||||
_button = '<input type="button" class="button button-small" />',
|
||||
_wrappingLabel = '<label></label>',
|
||||
_wrappingLabelText = '<span class="screen-reader-text"></span>';
|
||||
_wrappingLabelText = '<span class="screen-reader-text"></span>',
|
||||
__ = wp.i18n.__;
|
||||
|
||||
/**
|
||||
* Creates a jQuery UI color picker that is used in the theme customizer.
|
||||
@ -118,7 +118,7 @@
|
||||
// Insert the default label text.
|
||||
self.wrappingLabelText = $( _wrappingLabelText )
|
||||
.insertBefore( el )
|
||||
.text( wpColorPickerL10n.defaultLabel );
|
||||
.text( __( 'Color value' ) );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -136,7 +136,7 @@
|
||||
.insertBefore( self.wrappingLabel )
|
||||
.css( { backgroundColor: self.initialValue } );
|
||||
// Set the toggle button span element text.
|
||||
self.toggler.find( '.wp-color-result-text' ).text( wpColorPickerL10n.pick );
|
||||
self.toggler.find( '.wp-color-result-text' ).text( __( 'Select Color' ) );
|
||||
// Set up the Iris container and insert it after the wrapping label.
|
||||
self.pickerContainer = $( _after ).insertAfter( self.wrappingLabel );
|
||||
// Store a reference to the Clear/Default button.
|
||||
@ -146,13 +146,13 @@
|
||||
if ( self.options.defaultColor ) {
|
||||
self.button
|
||||
.addClass( 'wp-picker-default' )
|
||||
.val( wpColorPickerL10n.defaultString )
|
||||
.attr( 'aria-label', wpColorPickerL10n.defaultAriaLabel );
|
||||
.val( __( 'Default' ) )
|
||||
.attr( 'aria-label', __( 'Select default color' ) );
|
||||
} else {
|
||||
self.button
|
||||
.addClass( 'wp-picker-clear' )
|
||||
.val( wpColorPickerL10n.clear )
|
||||
.attr( 'aria-label', wpColorPickerL10n.clearAriaLabel );
|
||||
.val( __( 'Clear' ) )
|
||||
.attr( 'aria-label', __( 'Clear color' ) );
|
||||
}
|
||||
|
||||
// Wrap the wrapping label in its wrapper and append the Clear/Default button.
|
||||
|
@ -1349,18 +1349,7 @@ function wp_default_scripts( $scripts ) {
|
||||
|
||||
$scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 );
|
||||
$scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 );
|
||||
did_action( 'init' ) && $scripts->localize(
|
||||
'wp-color-picker',
|
||||
'wpColorPickerL10n',
|
||||
array(
|
||||
'clear' => __( 'Clear' ),
|
||||
'clearAriaLabel' => __( 'Clear color' ),
|
||||
'defaultString' => __( 'Default' ),
|
||||
'defaultAriaLabel' => __( 'Select default color' ),
|
||||
'pick' => __( 'Select Color' ),
|
||||
'defaultLabel' => __( 'Color value' ),
|
||||
)
|
||||
);
|
||||
$scripts->set_translations( 'wp-color-picker' );
|
||||
|
||||
$scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y' ), false, 1 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user