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.
Built from https://develop.svn.wordpress.org/trunk@48392


git-svn-id: http://core.svn.wordpress.org/trunk@48161 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2020-07-07 18:15:03 +00:00
parent daf060bbd2
commit ac4f93a5be
4 changed files with 12 additions and 14 deletions

View File

@ -4,7 +4,7 @@
* @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( $ ) {
@ -156,7 +156,13 @@ jQuery( document ).ready( function( $ ) {
*/
$( '.wrap' ).on( 'click', '.thickbox.open-plugin-details-modal', function( e ) {
// 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.stopPropagation();
@ -170,7 +176,7 @@ jQuery( document ).ready( function( $ ) {
tbWindow
.attr({
'role': 'dialog',
'aria-label': plugininstallL10n.plugin_modal_label
'aria-label': wp.i18n.__( 'Plugin details' )
})
.addClass( 'plugin-details-modal' );

View File

@ -1,2 +1,2 @@
/*! This file is auto-generated */
jQuery(document).ready(function(o){var a,i,n,e,l,d=o(),s=o(".upload-view-toggle"),t=o(".wrap"),r=o(document.body);function u(){var t;n=o(":tabbable",i),e=a.find("#TB_closeWindowButton"),l=n.last(),(t=e.add(l)).off("keydown.wp-plugin-details"),t.on("keydown.wp-plugin-details",function(t){!function(t){if(9!==t.which)return;l[0]!==t.target||t.shiftKey?e[0]===t.target&&t.shiftKey&&(t.preventDefault(),l.focus()):(t.preventDefault(),e.focus())}(t)})}window.tb_position=function(){var t=o(window).width(),i=o(window).height()-(792<t?60:20),n=792<t?772:t-20;return(a=o("#TB_window")).length&&(a.width(n).height(i),o("#TB_iframeContent").width(n).height(i),a.css({"margin-left":"-"+parseInt(n/2,10)+"px"}),void 0!==document.body.style.maxWidth&&a.css({top:"30px","margin-top":"0"})),o("a.thickbox").each(function(){var t=o(this).attr("href");t&&(t=(t=t.replace(/&width=[0-9]+/g,"")).replace(/&height=[0-9]+/g,""),o(this).attr("href",t+"&width="+n+"&height="+i))})},o(window).resize(function(){tb_position()}),r.on("thickbox:iframe:loaded",a,function(){a.hasClass("plugin-details-modal")&&function(){var t=a.find("#TB_iframeContent");i=t.contents().find("body"),u(),e.focus(),o("#plugin-information-tabs a",i).on("click",function(){u()}),i.on("keydown",function(t){27===t.which&&tb_remove()})}()}).on("thickbox:removed",function(){d.focus()}),o(".wrap").on("click",".thickbox.open-plugin-details-modal",function(t){var i=o(this).data("title")?plugininstallL10n.plugin_information+" "+o(this).data("title"):plugininstallL10n.plugin_modal_label;t.preventDefault(),t.stopPropagation(),d=o(this),tb_click.call(this),a.attr({role:"dialog","aria-label":plugininstallL10n.plugin_modal_label}).addClass("plugin-details-modal"),a.find("#TB_iframeContent").attr("title",i)}),o("#plugin-information-tabs a").click(function(t){var i=o(this).attr("name");t.preventDefault(),o("#plugin-information-tabs a.current").removeClass("current"),o(this).addClass("current"),"description"!==i&&o(window).width()<772?o("#plugin-information-content").find(".fyi").hide():o("#plugin-information-content").find(".fyi").show(),o("#section-holder div.section").hide(),o("#section-"+i).show()}),t.hasClass("plugin-install-tab-upload")||s.attr({role:"button","aria-expanded":"false"}).on("click",function(t){t.preventDefault(),r.toggleClass("show-upload-view"),s.attr("aria-expanded",r.hasClass("show-upload-view"))})});
jQuery(document).ready(function(o){var e,i,n,a,l,d=o(),s=o(".upload-view-toggle"),t=o(".wrap"),r=o(document.body);function c(){var t;n=o(":tabbable",i),a=e.find("#TB_closeWindowButton"),l=n.last(),(t=a.add(l)).off("keydown.wp-plugin-details"),t.on("keydown.wp-plugin-details",function(t){!function(t){if(9!==t.which)return;l[0]!==t.target||t.shiftKey?a[0]===t.target&&t.shiftKey&&(t.preventDefault(),l.focus()):(t.preventDefault(),a.focus())}(t)})}window.tb_position=function(){var t=o(window).width(),i=o(window).height()-(792<t?60:20),n=792<t?772:t-20;return(e=o("#TB_window")).length&&(e.width(n).height(i),o("#TB_iframeContent").width(n).height(i),e.css({"margin-left":"-"+parseInt(n/2,10)+"px"}),void 0!==document.body.style.maxWidth&&e.css({top:"30px","margin-top":"0"})),o("a.thickbox").each(function(){var t=o(this).attr("href");t&&(t=(t=t.replace(/&width=[0-9]+/g,"")).replace(/&height=[0-9]+/g,""),o(this).attr("href",t+"&width="+n+"&height="+i))})},o(window).resize(function(){tb_position()}),r.on("thickbox:iframe:loaded",e,function(){e.hasClass("plugin-details-modal")&&function(){var t=e.find("#TB_iframeContent");i=t.contents().find("body"),c(),a.focus(),o("#plugin-information-tabs a",i).on("click",function(){c()}),i.on("keydown",function(t){27===t.which&&tb_remove()})}()}).on("thickbox:removed",function(){d.focus()}),o(".wrap").on("click",".thickbox.open-plugin-details-modal",function(t){var i=o(this).data("title")?wp.i18n.sprintf(wp.i18n.__("Plugin: %s"),o(this).data("title")):wp.i18n.__("Plugin details");t.preventDefault(),t.stopPropagation(),d=o(this),tb_click.call(this),e.attr({role:"dialog","aria-label":wp.i18n.__("Plugin details")}).addClass("plugin-details-modal"),e.find("#TB_iframeContent").attr("title",i)}),o("#plugin-information-tabs a").click(function(t){var i=o(this).attr("name");t.preventDefault(),o("#plugin-information-tabs a.current").removeClass("current"),o(this).addClass("current"),"description"!==i&&o(window).width()<772?o("#plugin-information-content").find(".fyi").hide():o("#plugin-information-content").find(".fyi").show(),o("#section-holder div.section").hide(),o("#section-"+i).show()}),t.hasClass("plugin-install-tab-upload")||s.attr({role:"button","aria-expanded":"false"}).on("click",function(t){t.preventDefault(),r.toggleClass("show-upload-view"),s.attr("aria-expanded",r.hasClass("show-upload-view"))})});

View File

@ -1260,15 +1260,7 @@ function wp_default_scripts( $scripts ) {
$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 );
did_action( 'init' ) && $scripts->localize(
'plugin-install',
'plugininstallL10n',
array(
'plugin_information' => __( 'Plugin:' ),
'plugin_modal_label' => __( 'Plugin details' ),
'ays' => __( 'Are you sure you want to install this plugin?' ),
)
);
$scripts->set_translations( 'plugin-install' );
$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' );

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48391';
$wp_version = '5.5-alpha-48392';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.