Make WordPress Core


Ignore:
Timestamp:
07/07/2020 04:12:14 PM (5 years ago)
Author:
ocean90
Message:

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

File:
1 edited

Legend:

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

    r48383 r48384  
    13581358        $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 );
    13591359        $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 );
    1360         did_action( 'init' ) && $scripts->localize(
    1361             'media',
    1362             'attachMediaBoxL10n',
    1363             array(
    1364                 'error' => __( 'An error has occurred. Please reload the page and try again.' ),
    1365             )
    1366         );
     1360        $scripts->set_translations( 'media' );
    13671361
    13681362        $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y' ), false, 1 );
Note: See TracChangeset for help on using the changeset viewer.