From 0d00b776ec8e1eeff5cc23e1b599cc9db35664fe Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Mon, 6 Jul 2020 19:45:04 +0000 Subject: [PATCH] I18N: Use `wp.i18n` for translatable strings in `wp-admin/js/tags.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 #50577. git-svn-id: https://develop.svn.wordpress.org/trunk@48347 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/tags.js | 6 +++--- src/wp-includes/script-loader.php | 9 +-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/js/_enqueues/admin/tags.js b/src/js/_enqueues/admin/tags.js index d652ad06d9..a0708b3f42 100644 --- a/src/js/_enqueues/admin/tags.js +++ b/src/js/_enqueues/admin/tags.js @@ -7,7 +7,7 @@ * @output wp-admin/js/tags.js */ - /* global ajaxurl, wpAjax, tagsl10n, showNotice, validateForm */ + /* global ajaxurl, wpAjax, showNotice, validateForm */ jQuery(document).ready(function($) { @@ -55,11 +55,11 @@ jQuery(document).ready(function($) { $('a.tag-link-' + data.match(/tag_ID=(\d+)/)[1]).remove(); } else if ( '-1' == r ) { - $('#ajax-response').empty().append('

' + tagsl10n.noPerm + '

'); + $('#ajax-response').empty().append('

' + wp.i18n.__( 'Sorry, you are not allowed to do that.' ) + '

'); tr.children().css('backgroundColor', ''); } else { - $('#ajax-response').empty().append('

' + tagsl10n.broken + '

'); + $('#ajax-response').empty().append('

' + wp.i18n.__( 'Something went wrong.' ) + '

'); tr.children().css('backgroundColor', ''); } }); diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 7ebb7e3a43..e2c1956196 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1193,14 +1193,7 @@ function wp_default_scripts( $scripts ) { if ( is_admin() ) { $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 ); - did_action( 'init' ) && $scripts->localize( - 'admin-tags', - 'tagsl10n', - array( - 'noPerm' => __( 'Sorry, you are not allowed to do that.' ), - 'broken' => __( 'Something went wrong.' ), - ) - ); + $scripts->set_translations( 'admin-tags' ); $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array( 'wp-lists', 'quicktags', 'jquery-query' ), false, 1 ); did_action( 'init' ) && $scripts->localize(