Make WordPress Core


Ignore:
Timestamp:
07/07/2020 06:28:41 PM (5 years ago)
Author:
ocean90
Message:

I18N: Use wp.i18n for translatable strings in wp-admin/js/nav-menu.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 #50603.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r48392 r48394  
    13131313         */
    13141314        $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2', 'underscore' ) );
    1315         did_action( 'init' ) && $scripts->localize(
    1316             'nav-menu',
    1317             'navMenuL10n',
    1318             array(
    1319                 'noResultsFound' => __( 'No results found.' ),
    1320                 'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
    1321                 'saveAlert'      => __( 'The changes you made will be lost if you navigate away from this page.' ),
    1322                 'untitled'       => _x( '(no label)', 'missing menu item navigation label' ),
    1323             )
    1324         );
     1315        $scripts->set_translations( 'nav-menu' );
    13251316
    13261317        $scripts->add( 'custom-header', '/wp-admin/js/custom-header.js', array( 'jquery-masonry' ), false, 1 );
Note: See TracChangeset for help on using the changeset viewer.