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.

git-svn-id: https://develop.svn.wordpress.org/trunk@48395 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling 2020-07-07 18:38:20 +00:00
parent 189f23fd27
commit 25417b5d49
2 changed files with 6 additions and 14 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

@ -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' ) );