I18N: Use wp.i18n for translatable strings in wp-admin/js/inline-edit-post.js and wp-admin/js/inline-edit-tax.js.

This removes the usage of `wp_localize_script()` for passing translations to the scripts and instead adds the translatable strings in the scripts directly through the use of `wp.i18n` and its utilities.

Props swissspidy, ocean90.
See #20491.
Fixes #50601.

git-svn-id: https://develop.svn.wordpress.org/trunk@48391 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling
2020-07-07 18:00:37 +00:00
parent 289c28637c
commit 849e7bfdc8
3 changed files with 13 additions and 30 deletions
+7 -7
View File
@@ -5,7 +5,7 @@
* @output wp-admin/js/inline-edit-post.js
*/
/* global inlineEditL10n, ajaxurl, typenow, inlineEditPost */
/* global ajaxurl, typenow, inlineEditPost */
window.wp = window.wp || {};
@@ -198,8 +198,8 @@ window.wp = window.wp || {};
if ( $(this).prop('checked') ) {
c = false;
var id = $(this).val(), theTitle;
theTitle = $('#inline_'+id+' .post_title').html() || inlineEditL10n.notitle;
te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>';
theTitle = $('#inline_'+id+' .post_title').html() || wp.i18n.__( '(no title)' );
te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+ wp.i18n.__( 'Remove From Bulk Edit' ) +'">X</a>'+theTitle+'</div>';
}
});
@@ -327,7 +327,7 @@ window.wp = window.wp || {};
var terms = $(this),
taxname = $(this).attr('id').replace('_' + id, ''),
textarea = $('textarea.tax_input_' + taxname, editRow),
comma = inlineEditL10n.comma;
comma = wp.i18n._x( ',', 'tag delimiter' ).trim();
terms.find( 'img' ).replaceWith( function() { return this.alt; } );
terms = terms.text();
@@ -431,7 +431,7 @@ window.wp = window.wp || {};
$( this ).find( '.editinline' )
.attr( 'aria-expanded', 'false' )
.focus();
wp.a11y.speak( inlineEditL10n.saved );
wp.a11y.speak( wp.i18n.__( 'Changes saved.' ) );
});
} else {
r = r.replace( /<.[^<>]*?>/g, '' );
@@ -441,8 +441,8 @@ window.wp = window.wp || {};
}
} else {
$errorNotice.removeClass( 'hidden' );
$error.html( inlineEditL10n.error );
wp.a11y.speak( inlineEditL10n.error );
$error.text( wp.i18n.__( 'Error while saving the changes.' ) );
wp.a11y.speak( wp.i18n.__( 'Error while saving the changes.' ) );
}
},
'html');
+4 -4
View File
@@ -4,7 +4,7 @@
* @output wp-admin/js/inline-edit-tax.js
*/
/* global inlineEditL10n, ajaxurl, inlineEditTax */
/* global ajaxurl, inlineEditTax */
window.wp = window.wp || {};
@@ -224,7 +224,7 @@ window.inlineEditTax = {
row.find( '.editinline' )
.attr( 'aria-expanded', 'false' )
.focus();
wp.a11y.speak( inlineEditL10n.saved );
wp.a11y.speak( wp.i18n.__( 'Changes saved.' ) );
});
} else {
@@ -238,8 +238,8 @@ window.inlineEditTax = {
}
} else {
$errorNotice.removeClass( 'hidden' );
$error.html( inlineEditL10n.error );
wp.a11y.speak( inlineEditL10n.error );
$error.text( wp.i18n.__( 'Error while saving the changes.' ) );
wp.a11y.speak( wp.i18n.__( 'Error while saving the changes.' ) );
}
}
);