I18N: Use `wp.i18n` for translatable strings in `wp-admin/js/comment.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 #50604.
Built from https://develop.svn.wordpress.org/trunk@48395


git-svn-id: http://core.svn.wordpress.org/trunk@48164 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2020-07-07 18:40:05 +00:00
parent 291f3d76ec
commit 0dc81cc24f
4 changed files with 8 additions and 16 deletions

View File

@ -2,7 +2,7 @@
* @output wp-admin/js/comment.js
*/
/* global postboxes, commentL10n */
/* global postboxes */
/**
* Binds to the document ready event.
@ -84,8 +84,9 @@ jQuery(document).ready( function($) {
}
$timestamp.html(
commentL10n.submittedOn + ' <b>' +
commentL10n.dateFormat
wp.i18n.__( 'Submitted on:' ) + ' <b>' +
/* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
wp.i18n.__( '%1$s %2$s, %3$s at %4$s:%5$s' )
.replace( '%1$s', $( 'option[value="' + mm + '"]', '#mm' ).attr( 'data-text' ) )
.replace( '%2$s', parseInt( jj, 10 ) )
.replace( '%3$s', aa )

View File

@ -1,2 +1,2 @@
/*! This file is auto-generated */
jQuery(document).ready(function(m){postboxes.add_postbox_toggles("comment");var d=m("#timestampdiv"),c=m("#timestamp"),a=c.html(),o=d.find(".timestamp-wrap"),v=d.siblings("a.edit-timestamp");v.click(function(e){d.is(":hidden")&&(d.slideDown("fast",function(){m("input, select",o).first().focus()}),m(this).hide()),e.preventDefault()}),d.find(".cancel-timestamp").click(function(e){v.show().focus(),d.slideUp("fast"),m("#mm").val(m("#hidden_mm").val()),m("#jj").val(m("#hidden_jj").val()),m("#aa").val(m("#hidden_aa").val()),m("#hh").val(m("#hidden_hh").val()),m("#mn").val(m("#hidden_mn").val()),c.html(a),e.preventDefault()}),d.find(".save-timestamp").click(function(e){var a=m("#aa").val(),t=m("#mm").val(),l=m("#jj").val(),i=m("#hh").val(),n=m("#mn").val(),s=new Date(a,t-1,l,i,n);e.preventDefault(),s.getFullYear()==a&&1+s.getMonth()==t&&s.getDate()==l&&s.getMinutes()==n?(o.removeClass("form-invalid"),c.html(commentL10n.submittedOn+" <b>"+commentL10n.dateFormat.replace("%1$s",m('option[value="'+t+'"]',"#mm").attr("data-text")).replace("%2$s",parseInt(l,10)).replace("%3$s",a).replace("%4$s",("00"+i).slice(-2)).replace("%5$s",("00"+n).slice(-2))+"</b> "),v.show().focus(),d.slideUp("fast")):o.addClass("form-invalid")})});
jQuery(document).ready(function(m){postboxes.add_postbox_toggles("comment");var d=m("#timestampdiv"),c=m("#timestamp"),a=c.html(),v=d.find(".timestamp-wrap"),o=d.siblings("a.edit-timestamp");o.click(function(e){d.is(":hidden")&&(d.slideDown("fast",function(){m("input, select",v).first().focus()}),m(this).hide()),e.preventDefault()}),d.find(".cancel-timestamp").click(function(e){o.show().focus(),d.slideUp("fast"),m("#mm").val(m("#hidden_mm").val()),m("#jj").val(m("#hidden_jj").val()),m("#aa").val(m("#hidden_aa").val()),m("#hh").val(m("#hidden_hh").val()),m("#mn").val(m("#hidden_mn").val()),c.html(a),e.preventDefault()}),d.find(".save-timestamp").click(function(e){var a=m("#aa").val(),t=m("#mm").val(),i=m("#jj").val(),s=m("#hh").val(),l=m("#mn").val(),n=new Date(a,t-1,i,s,l);e.preventDefault(),n.getFullYear()==a&&1+n.getMonth()==t&&n.getDate()==i&&n.getMinutes()==l?(v.removeClass("form-invalid"),c.html(wp.i18n.__("Submitted on:")+" <b>"+wp.i18n.__("%1$s %2$s, %3$s at %4$s:%5$s").replace("%1$s",m('option[value="'+t+'"]',"#mm").attr("data-text")).replace("%2$s",parseInt(i,10)).replace("%3$s",a).replace("%4$s",("00"+s).slice(-2)).replace("%5$s",("00"+l).slice(-2))+"</b> "),o.show().focus(),d.slideUp("fast")):v.addClass("form-invalid")})});

View File

@ -1224,17 +1224,8 @@ function wp_default_scripts( $scripts ) {
$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
$scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) );
$scripts->add_data( 'comment', 'group', 1 );
did_action( 'init' ) && $scripts->localize(
'comment',
'commentL10n',
array(
'submittedOn' => __( 'Submitted on:' ),
/* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
'dateFormat' => __( '%1$s %2$s, %3$s at %4$s:%5$s' ),
)
);
$scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ), false, 1 );
$scripts->set_translations( 'comment' );
$scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) );

View File

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