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. git-svn-id: https://develop.svn.wordpress.org/trunk@48384 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e39812fe53
commit
b24fbd088b
@ -10,7 +10,7 @@
|
|||||||
* @requires jQuery
|
* @requires jQuery
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global ajaxurl, attachMediaBoxL10n, _wpMediaGridSettings, showNotice, findPosts */
|
/* global ajaxurl, _wpMediaGridSettings, showNotice, findPosts */
|
||||||
|
|
||||||
( function( $ ){
|
( function( $ ){
|
||||||
window.findPosts = {
|
window.findPosts = {
|
||||||
@ -124,12 +124,12 @@
|
|||||||
spinner.removeClass( 'is-active' );
|
spinner.removeClass( 'is-active' );
|
||||||
}).done( function( x ) {
|
}).done( function( x ) {
|
||||||
if ( ! x.success ) {
|
if ( ! x.success ) {
|
||||||
$( '#find-posts-response' ).text( attachMediaBoxL10n.error );
|
$( '#find-posts-response' ).text( wp.i18n.__( 'An error has occurred. Please reload the page and try again.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$( '#find-posts-response' ).html( x.data );
|
$( '#find-posts-response' ).html( x.data );
|
||||||
}).fail( function() {
|
}).fail( function() {
|
||||||
$( '#find-posts-response' ).text( attachMediaBoxL10n.error );
|
$( '#find-posts-response' ).text( wp.i18n.__( 'An error has occurred. Please reload the page and try again.' ) );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1357,13 +1357,7 @@ function wp_default_scripts( $scripts ) {
|
|||||||
|
|
||||||
$scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 );
|
$scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 );
|
||||||
$scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 );
|
$scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 );
|
||||||
did_action( 'init' ) && $scripts->localize(
|
$scripts->set_translations( 'media' );
|
||||||
'media',
|
|
||||||
'attachMediaBoxL10n',
|
|
||||||
array(
|
|
||||||
'error' => __( 'An error has occurred. Please reload the page and try again.' ),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y' ), false, 1 );
|
$scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y' ), false, 1 );
|
||||||
$scripts->set_translations( 'image-edit' );
|
$scripts->set_translations( 'image-edit' );
|
||||||
|
Loading…
Reference in New Issue
Block a user