From 7e7b70cd1ae5772229abb769d0823411112c748b Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 7 Jul 2020 16:10:05 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@48383 git-svn-id: http://core.svn.wordpress.org/trunk@48152 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/color-picker.js | 16 ++++++++-------- wp-admin/js/color-picker.min.js | 2 +- wp-includes/script-loader.php | 13 +------------ wp-includes/version.php | 2 +- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/wp-admin/js/color-picker.js b/wp-admin/js/color-picker.js index 18f2bc26dc..83e7dc663e 100644 --- a/wp-admin/js/color-picker.js +++ b/wp-admin/js/color-picker.js @@ -2,7 +2,6 @@ * @output wp-admin/js/color-picker.js */ -/* global wpColorPickerL10n */ ( function( $, undef ) { var ColorPicker, @@ -11,7 +10,8 @@ _wrap = '
', _button = '', _wrappingLabel = '', - _wrappingLabelText = ''; + _wrappingLabelText = '', + __ = 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. diff --git a/wp-admin/js/color-picker.min.js b/wp-admin/js/color-picker.min.js index 3f690c6e0b..8fd8723243 100644 --- a/wp-admin/js/color-picker.min.js +++ b/wp-admin/js/color-picker.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(i,t){var e;e={options:{defaultColor:!1,change:!1,clear:!1,hide:!0,palettes:!0,width:255,mode:"hsv",type:"full",slider:"horizontal"},_createHueOnly:function(){var e,o=this,t=o.element;t.hide(),e="hsl("+t.val()+", 100, 50)",t.iris({mode:"hsl",type:"hue",hide:!1,color:e,change:function(e,t){i.isFunction(o.options.change)&&o.options.change.call(this,e,t)},width:o.options.width,slider:o.options.slider})},_create:function(){if(i.support.iris){var o=this,e=o.element;if(i.extend(o.options,e.data()),"hue"===o.options.type)return o._createHueOnly();o.close=i.proxy(o.close,o),o.initialValue=e.val(),e.addClass("wp-color-picker"),e.parent("label").length||(e.wrap(""),o.wrappingLabelText=i('').insertBefore(e).text(wpColorPickerL10n.defaultLabel)),o.wrappingLabel=e.parent(),o.wrappingLabel.wrap('
'),o.wrap=o.wrappingLabel.parent(),o.toggler=i('').insertBefore(o.wrappingLabel).css({backgroundColor:o.initialValue}),o.toggler.find(".wp-color-result-text").text(wpColorPickerL10n.pick),o.pickerContainer=i('
').insertAfter(o.wrappingLabel),o.button=i(''),o.options.defaultColor?o.button.addClass("wp-picker-default").val(wpColorPickerL10n.defaultString).attr("aria-label",wpColorPickerL10n.defaultAriaLabel):o.button.addClass("wp-picker-clear").val(wpColorPickerL10n.clear).attr("aria-label",wpColorPickerL10n.clearAriaLabel),o.wrappingLabel.wrap('