mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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. Built from https://develop.svn.wordpress.org/trunk@48391 git-svn-id: http://core.svn.wordpress.org/trunk@48160 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
49bbff551b
commit
daf060bbd2
@ -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');
|
||||
|
2
wp-admin/js/inline-edit-post.min.js
vendored
2
wp-admin/js/inline-edit-post.min.js
vendored
File diff suppressed because one or more lines are too long
@ -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.' ) );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
2
wp-admin/js/inline-edit-tax.min.js
vendored
2
wp-admin/js/inline-edit-tax.min.js
vendored
@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
window.wp=window.wp||{},function(s,l){window.inlineEditTax={init:function(){var t=this,i=s("#inline-edit");t.type=s("#the-list").attr("data-wp-lists").substr(5),t.what="#"+t.type+"-",s("#the-list").on("click",".editinline",function(){s(this).attr("aria-expanded","true"),inlineEditTax.edit(this)}),i.keyup(function(t){if(27===t.which)return inlineEditTax.revert()}),s(".cancel",i).click(function(){return inlineEditTax.revert()}),s(".save",i).click(function(){return inlineEditTax.save(this)}),s("input, select",i).keydown(function(t){if(13===t.which)return inlineEditTax.save(this)}),s('#posts-filter input[type="submit"]').mousedown(function(){t.revert()})},toggle:function(t){var i=this;"none"===s(i.what+i.getId(t)).css("display")?i.revert():i.edit(t)},edit:function(t){var i,e,n,a=this;return a.revert(),"object"==typeof t&&(t=a.getId(t)),i=s("#inline-edit").clone(!0),e=s("#inline_"+t),s("td",i).attr("colspan",s("th:visible, td:visible",".wp-list-table.widefat:first thead").length),s(a.what+t).hide().after(i).after('<tr class="hidden"></tr>'),(n=s(".name",e)).find("img").replaceWith(function(){return this.alt}),n=n.text(),s(':input[name="name"]',i).val(n),(n=s(".slug",e)).find("img").replaceWith(function(){return this.alt}),n=n.text(),s(':input[name="slug"]',i).val(n),s(i).attr("id","edit-"+t).addClass("inline-editor").show(),s(".ptitle",i).eq(0).focus(),!1},save:function(d){var t,i=s('input[name="taxonomy"]').val()||"";return"object"==typeof d&&(d=this.getId(d)),s("table.widefat .spinner").addClass("is-active"),t={action:"inline-save-tax",tax_type:this.type,tax_ID:d,taxonomy:i},t=s("#edit-"+d).find(":input").serialize()+"&"+s.param(t),s.post(ajaxurl,t,function(t){var i,e,n,a=s("#edit-"+d+" .inline-edit-save .notice-error"),r=a.find(".error");s("table.widefat .spinner").removeClass("is-active"),t?-1!==t.indexOf("<tr")?(s(inlineEditTax.what+d).siblings("tr.hidden").addBack().remove(),e=s(t).attr("id"),s("#edit-"+d).before(t).remove(),i=e?(n=e.replace(inlineEditTax.type+"-",""),s("#"+e)):(n=d,s(inlineEditTax.what+d)),s("#parent").find("option[value="+n+"]").text(i.find(".row-title").text()),i.hide().fadeIn(400,function(){i.find(".editinline").attr("aria-expanded","false").focus(),l.a11y.speak(inlineEditL10n.saved)})):(a.removeClass("hidden"),r.html(t),l.a11y.speak(r.text())):(a.removeClass("hidden"),r.html(inlineEditL10n.error),l.a11y.speak(inlineEditL10n.error))}),!1},revert:function(){var t=s("table.widefat tr.inline-editor").attr("id");t&&(s("table.widefat .spinner").removeClass("is-active"),s("#"+t).siblings("tr.hidden").addBack().remove(),t=t.substr(t.lastIndexOf("-")+1),s(this.what+t).show().find(".editinline").attr("aria-expanded","false").focus())},getId:function(t){var i=("TR"===t.tagName?t.id:s(t).parents("tr").attr("id")).split("-");return i[i.length-1]}},s(document).ready(function(){inlineEditTax.init()})}(jQuery,window.wp);
|
||||
window.wp=window.wp||{},function(s,l){window.inlineEditTax={init:function(){var t=this,e=s("#inline-edit");t.type=s("#the-list").attr("data-wp-lists").substr(5),t.what="#"+t.type+"-",s("#the-list").on("click",".editinline",function(){s(this).attr("aria-expanded","true"),inlineEditTax.edit(this)}),e.keyup(function(t){if(27===t.which)return inlineEditTax.revert()}),s(".cancel",e).click(function(){return inlineEditTax.revert()}),s(".save",e).click(function(){return inlineEditTax.save(this)}),s("input, select",e).keydown(function(t){if(13===t.which)return inlineEditTax.save(this)}),s('#posts-filter input[type="submit"]').mousedown(function(){t.revert()})},toggle:function(t){var e=this;"none"===s(e.what+e.getId(t)).css("display")?e.revert():e.edit(t)},edit:function(t){var e,i,n,a=this;return a.revert(),"object"==typeof t&&(t=a.getId(t)),e=s("#inline-edit").clone(!0),i=s("#inline_"+t),s("td",e).attr("colspan",s("th:visible, td:visible",".wp-list-table.widefat:first thead").length),s(a.what+t).hide().after(e).after('<tr class="hidden"></tr>'),(n=s(".name",i)).find("img").replaceWith(function(){return this.alt}),n=n.text(),s(':input[name="name"]',e).val(n),(n=s(".slug",i)).find("img").replaceWith(function(){return this.alt}),n=n.text(),s(':input[name="slug"]',e).val(n),s(e).attr("id","edit-"+t).addClass("inline-editor").show(),s(".ptitle",e).eq(0).focus(),!1},save:function(d){var t,e=s('input[name="taxonomy"]').val()||"";return"object"==typeof d&&(d=this.getId(d)),s("table.widefat .spinner").addClass("is-active"),t={action:"inline-save-tax",tax_type:this.type,tax_ID:d,taxonomy:e},t=s("#edit-"+d).find(":input").serialize()+"&"+s.param(t),s.post(ajaxurl,t,function(t){var e,i,n,a=s("#edit-"+d+" .inline-edit-save .notice-error"),r=a.find(".error");s("table.widefat .spinner").removeClass("is-active"),t?-1!==t.indexOf("<tr")?(s(inlineEditTax.what+d).siblings("tr.hidden").addBack().remove(),i=s(t).attr("id"),s("#edit-"+d).before(t).remove(),e=i?(n=i.replace(inlineEditTax.type+"-",""),s("#"+i)):(n=d,s(inlineEditTax.what+d)),s("#parent").find("option[value="+n+"]").text(e.find(".row-title").text()),e.hide().fadeIn(400,function(){e.find(".editinline").attr("aria-expanded","false").focus(),l.a11y.speak(l.i18n.__("Changes saved."))})):(a.removeClass("hidden"),r.html(t),l.a11y.speak(r.text())):(a.removeClass("hidden"),r.text(l.i18n.__("Error while saving the changes.")),l.a11y.speak(l.i18n.__("Error while saving the changes.")))}),!1},revert:function(){var t=s("table.widefat tr.inline-editor").attr("id");t&&(s("table.widefat .spinner").removeClass("is-active"),s("#"+t).siblings("tr.hidden").addBack().remove(),t=t.substr(t.lastIndexOf("-")+1),s(this.what+t).show().find(".editinline").attr("aria-expanded","false").focus())},getId:function(t){var e=("TR"===t.tagName?t.id:s(t).parents("tr").attr("id")).split("-");return e[e.length-1]}},s(document).ready(function(){inlineEditTax.init()})}(jQuery,window.wp);
|
@ -1254,27 +1254,10 @@ function wp_default_scripts( $scripts ) {
|
||||
$scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y', 'customize-base' ), false, 1 );
|
||||
|
||||
$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'tags-suggest', 'wp-a11y' ), false, 1 );
|
||||
did_action( 'init' ) && $scripts->localize(
|
||||
'inline-edit-post',
|
||||
'inlineEditL10n',
|
||||
array(
|
||||
'error' => __( 'Error while saving the changes.' ),
|
||||
'ntdeltitle' => __( 'Remove From Bulk Edit' ),
|
||||
'notitle' => __( '(no title)' ),
|
||||
'comma' => trim( _x( ',', 'tag delimiter' ) ),
|
||||
'saved' => __( 'Changes saved.' ),
|
||||
)
|
||||
);
|
||||
$scripts->set_translations( 'inline-edit-post' );
|
||||
|
||||
$scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
|
||||
did_action( 'init' ) && $scripts->localize(
|
||||
'inline-edit-tax',
|
||||
'inlineEditL10n',
|
||||
array(
|
||||
'error' => __( 'Error while saving the changes.' ),
|
||||
'saved' => __( 'Changes saved.' ),
|
||||
)
|
||||
);
|
||||
$scripts->set_translations( 'inline-edit-tax' );
|
||||
|
||||
$scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 );
|
||||
did_action( 'init' ) && $scripts->localize(
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-alpha-48390';
|
||||
$wp_version = '5.5-alpha-48391';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user