Make WordPress Core

Changeset 48396


Ignore:
Timestamp:
07/07/2020 06:53:50 PM (3 years ago)
Author:
ocean90
Message:

I18N: Use wp.i18n for translatable strings in wp-admin/js/set-post-thumbnail.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 #50605.

Location:
trunk/src
Files:
4 edited

Legend:

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

    r48385 r48396  
    55 */
    66
    7  /* global ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting, ClipboardJS */
     7 /* global ajaxurl, wpAjax, postboxes, pagenow, tinymce, alert, deleteUserSetting, ClipboardJS */
    88 /* global theList:true, theExtraList:true, getUserSetting, setUserSetting, commentReply, commentsBox */
    99 /* global WPSetThumbnailHTML, wptitlehint */
     
    146146            function(str){
    147147            if ( str == '0' ) {
    148                 alert( setPostThumbnailL10n.error );
     148                alert( __( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
    149149            } else {
    150150                WPSetThumbnailHTML(str);
  • trunk/src/js/_enqueues/admin/set-post-thumbnail.js

    r43577 r48396  
    33 */
    44
    5 /* global setPostThumbnailL10n, ajaxurl, post_id, alert */
     5/* global ajaxurl, post_id, alert */
    66/* exported WPSetAsThumbnail */
    77
     
    99    var $link = jQuery('a#wp-post-thumbnail-' + id);
    1010
    11     $link.text( setPostThumbnailL10n.saving );
     11    $link.text( wp.i18n.__( 'Saving…' ) );
    1212    jQuery.post(ajaxurl, {
    1313        action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
    1414    }, function(str){
    1515        var win = window.dialogArguments || opener || parent || top;
    16         $link.text( setPostThumbnailL10n.setThumbnail );
     16        $link.text( wp.i18n.__( 'Use as featured image' ) );
    1717        if ( str == '0' ) {
    18             alert( setPostThumbnailL10n.error );
     18            alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
    1919        } else {
    2020            jQuery('a.wp-post-thumbnail').show();
    21             $link.text( setPostThumbnailL10n.done );
     21            $link.text( wp.i18n.__( 'Done' ) );
    2222            $link.fadeOut( 2000 );
    2323            win.WPSetThumbnailID(id);
  • trunk/src/js/_enqueues/wp/media/editor.js

    r47349 r48396  
    628628            }).done( function( html ) {
    629629                if ( '0' === html ) {
    630                     window.alert( window.setPostThumbnailL10n.error );
     630                    window.alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
    631631                    return;
    632632                }
  • trunk/src/wp-includes/script-loader.php

    r48395 r48396  
    11871187
    11881188    $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
     1189    $scripts->set_translations( 'media-editor' );
    11891190    $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
    11901191    $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 );
     
    12881289
    12891290        $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
    1290         did_action( 'init' ) && $scripts->localize(
    1291             'set-post-thumbnail',
    1292             'setPostThumbnailL10n',
    1293             array(
    1294                 'setThumbnail' => __( 'Use as featured image' ),
    1295                 'saving'       => __( 'Saving...' ), // No ellipsis.
    1296                 'error'        => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
    1297                 'done'         => __( 'Done' ),
    1298             )
    1299         );
     1291        $scripts->set_translations( 'set-post-thumbnail' );
    13001292
    13011293        /*
Note: See TracChangeset for help on using the changeset viewer.