Make WordPress Core

Changeset 48347


Ignore:
Timestamp:
07/06/2020 07:45:04 PM (4 years ago)
Author:
ocean90
Message:

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.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/tags.js

    r48104 r48347  
    88 */
    99
    10  /* global ajaxurl, wpAjax, tagsl10n, showNotice, validateForm */
     10 /* global ajaxurl, wpAjax, showNotice, validateForm */
    1111
    1212jQuery(document).ready(function($) {
     
    5656
    5757                } else if ( '-1' == r ) {
    58                     $('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.noPerm + '</p></div>');
     58                    $('#ajax-response').empty().append('<div class="error"><p>' + wp.i18n.__( 'Sorry, you are not allowed to do that.' ) + '</p></div>');
    5959                    tr.children().css('backgroundColor', '');
    6060
    6161                } else {
    62                     $('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.broken + '</p></div>');
     62                    $('#ajax-response').empty().append('<div class="error"><p>' + wp.i18n.__( 'Something went wrong.' ) + '</p></div>');
    6363                    tr.children().css('backgroundColor', '');
    6464                }
  • trunk/src/wp-includes/script-loader.php

    r48346 r48347  
    11941194    if ( is_admin() ) {
    11951195        $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 );
    1196         did_action( 'init' ) && $scripts->localize(
    1197             'admin-tags',
    1198             'tagsl10n',
    1199             array(
    1200                 'noPerm' => __( 'Sorry, you are not allowed to do that.' ),
    1201                 'broken' => __( 'Something went wrong.' ),
    1202             )
    1203         );
     1196        $scripts->set_translations( 'admin-tags' );
    12041197
    12051198        $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array( 'wp-lists', 'quicktags', 'jquery-query' ), false, 1 );
Note: See TracChangeset for help on using the changeset viewer.