I18N: Use wp.i18n
for translatable strings in wp-admin/js/plugin-install.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 #50602. git-svn-id: https://develop.svn.wordpress.org/trunk@48392 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
849e7bfdc8
commit
f0c4b2c12e
@ -4,7 +4,7 @@
|
|||||||
* @output wp-admin/js/plugin-install.js
|
* @output wp-admin/js/plugin-install.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global plugininstallL10n, tb_click, tb_remove, tb_position */
|
/* global tb_click, tb_remove, tb_position */
|
||||||
|
|
||||||
jQuery( document ).ready( function( $ ) {
|
jQuery( document ).ready( function( $ ) {
|
||||||
|
|
||||||
@ -156,7 +156,13 @@ jQuery( document ).ready( function( $ ) {
|
|||||||
*/
|
*/
|
||||||
$( '.wrap' ).on( 'click', '.thickbox.open-plugin-details-modal', function( e ) {
|
$( '.wrap' ).on( 'click', '.thickbox.open-plugin-details-modal', function( e ) {
|
||||||
// The `data-title` attribute is used only in the Plugin screens.
|
// The `data-title` attribute is used only in the Plugin screens.
|
||||||
var title = $( this ).data( 'title' ) ? plugininstallL10n.plugin_information + ' ' + $( this ).data( 'title' ) : plugininstallL10n.plugin_modal_label;
|
var title = $( this ).data( 'title' ) ?
|
||||||
|
wp.i18n.sprintf(
|
||||||
|
// translators: %s: Plugin name.
|
||||||
|
wp.i18n.__( 'Plugin: %s' ),
|
||||||
|
$( this ).data( 'title' )
|
||||||
|
) :
|
||||||
|
wp.i18n.__( 'Plugin details' );
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@ -170,7 +176,7 @@ jQuery( document ).ready( function( $ ) {
|
|||||||
tbWindow
|
tbWindow
|
||||||
.attr({
|
.attr({
|
||||||
'role': 'dialog',
|
'role': 'dialog',
|
||||||
'aria-label': plugininstallL10n.plugin_modal_label
|
'aria-label': wp.i18n.__( 'Plugin details' )
|
||||||
})
|
})
|
||||||
.addClass( 'plugin-details-modal' );
|
.addClass( 'plugin-details-modal' );
|
||||||
|
|
||||||
|
@ -1260,15 +1260,7 @@ function wp_default_scripts( $scripts ) {
|
|||||||
$scripts->set_translations( 'inline-edit-tax' );
|
$scripts->set_translations( 'inline-edit-tax' );
|
||||||
|
|
||||||
$scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 );
|
$scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 );
|
||||||
did_action( 'init' ) && $scripts->localize(
|
$scripts->set_translations( 'plugin-install' );
|
||||||
'plugin-install',
|
|
||||||
'plugininstallL10n',
|
|
||||||
array(
|
|
||||||
'plugin_information' => __( 'Plugin:' ),
|
|
||||||
'plugin_modal_label' => __( 'Plugin details' ),
|
|
||||||
'ays' => __( 'Are you sure you want to install this plugin?' ),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
|
$scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
|
||||||
$scripts->set_translations( 'site-health' );
|
$scripts->set_translations( 'site-health' );
|
||||||
|
Loading…
Reference in New Issue
Block a user