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. git-svn-id: https://develop.svn.wordpress.org/trunk@48396 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
25417b5d49
commit
a7dc1bbef1
@ -4,7 +4,7 @@
|
||||
* @output wp-admin/js/post.js
|
||||
*/
|
||||
|
||||
/* global ajaxurl, wpAjax, setPostThumbnailL10n, postboxes, pagenow, tinymce, alert, deleteUserSetting, ClipboardJS */
|
||||
/* global ajaxurl, wpAjax, postboxes, pagenow, tinymce, alert, deleteUserSetting, ClipboardJS */
|
||||
/* global theList:true, theExtraList:true, getUserSetting, setUserSetting, commentReply, commentsBox */
|
||||
/* global WPSetThumbnailHTML, wptitlehint */
|
||||
|
||||
@ -145,7 +145,7 @@ window.wp = window.wp || {};
|
||||
*/
|
||||
function(str){
|
||||
if ( str == '0' ) {
|
||||
alert( setPostThumbnailL10n.error );
|
||||
alert( __( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
|
||||
} else {
|
||||
WPSetThumbnailHTML(str);
|
||||
}
|
||||
|
@ -2,23 +2,23 @@
|
||||
* @output wp-admin/js/set-post-thumbnail.js
|
||||
*/
|
||||
|
||||
/* global setPostThumbnailL10n, ajaxurl, post_id, alert */
|
||||
/* global ajaxurl, post_id, alert */
|
||||
/* exported WPSetAsThumbnail */
|
||||
|
||||
window.WPSetAsThumbnail = function( id, nonce ) {
|
||||
var $link = jQuery('a#wp-post-thumbnail-' + id);
|
||||
|
||||
$link.text( setPostThumbnailL10n.saving );
|
||||
$link.text( wp.i18n.__( 'Saving…' ) );
|
||||
jQuery.post(ajaxurl, {
|
||||
action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
|
||||
}, function(str){
|
||||
var win = window.dialogArguments || opener || parent || top;
|
||||
$link.text( setPostThumbnailL10n.setThumbnail );
|
||||
$link.text( wp.i18n.__( 'Use as featured image' ) );
|
||||
if ( str == '0' ) {
|
||||
alert( setPostThumbnailL10n.error );
|
||||
alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
|
||||
} else {
|
||||
jQuery('a.wp-post-thumbnail').show();
|
||||
$link.text( setPostThumbnailL10n.done );
|
||||
$link.text( wp.i18n.__( 'Done' ) );
|
||||
$link.fadeOut( 2000 );
|
||||
win.WPSetThumbnailID(id);
|
||||
win.WPSetThumbnailHTML(str);
|
||||
|
@ -627,7 +627,7 @@
|
||||
_wpnonce: settings.post.nonce
|
||||
}).done( function( html ) {
|
||||
if ( '0' === html ) {
|
||||
window.alert( window.setPostThumbnailL10n.error );
|
||||
window.alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
|
||||
return;
|
||||
}
|
||||
$( '.inside', '#postimagediv' ).html( html );
|
||||
|
@ -1186,6 +1186,7 @@ function wp_default_scripts( $scripts ) {
|
||||
$scripts->set_translations( 'media-views' );
|
||||
|
||||
$scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
|
||||
$scripts->set_translations( 'media-editor' );
|
||||
$scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
|
||||
$scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 );
|
||||
|
||||
@ -1287,16 +1288,7 @@ function wp_default_scripts( $scripts ) {
|
||||
$scripts->set_translations( 'image-edit' );
|
||||
|
||||
$scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
|
||||
did_action( 'init' ) && $scripts->localize(
|
||||
'set-post-thumbnail',
|
||||
'setPostThumbnailL10n',
|
||||
array(
|
||||
'setThumbnail' => __( 'Use as featured image' ),
|
||||
'saving' => __( 'Saving...' ), // No ellipsis.
|
||||
'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
|
||||
'done' => __( 'Done' ),
|
||||
)
|
||||
);
|
||||
$scripts->set_translations( 'set-post-thumbnail' );
|
||||
|
||||
/*
|
||||
* Navigation Menus: Adding underscore as a dependency to utilize _.debounce
|
||||
|
Loading…
Reference in New Issue
Block a user