Comments: Dynamically update the document title text for all languages, not only English.

See [33821].
Fixes #33414.

git-svn-id: https://develop.svn.wordpress.org/trunk@35615 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2015-11-11 20:59:56 +00:00
parent de44d6b375
commit 4d5fbe29f4
2 changed files with 6 additions and 3 deletions

View File

@ -98,7 +98,7 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved,
updateHtmlTitle = function ( diff ) {
var newTitle, regExMatch, titleCount, commentFrag;
titleRegEx = titleRegEx || new RegExp( 'Comments (\\([0-9' + thousandsSeparator + ']+\\))?' );
titleRegEx = titleRegEx || new RegExp( adminCommentsL10n.docTitleCommentsCount.replace( '%s', '\\([0-9' + thousandsSeparator + ']+\\)' ) + '?' );
// count funcs operate on a $'d element
titleDiv = titleDiv || $( '<div />' );
newTitle = adminTitle;
@ -117,12 +117,12 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved,
updateCount( titleDiv, titleCount );
regExMatch = titleRegEx.exec( document.title );
if ( regExMatch ) {
newTitle = document.title.replace( regExMatch[0], 'Comments (' + titleDiv.text() + ') ' );
newTitle = document.title.replace( regExMatch[0], adminCommentsL10n.docTitleCommentsCount.replace( '%s', titleDiv.text() ) + ' ' );
}
} else {
regExMatch = titleRegEx.exec( newTitle );
if ( regExMatch ) {
newTitle = newTitle.replace( regExMatch[0], 'Comments' );
newTitle = newTitle.replace( regExMatch[0], adminCommentsL10n.docTitleComments );
}
}
document.title = newTitle;

View File

@ -487,6 +487,9 @@ function wp_default_scripts( &$scripts ) {
'replyApprove' => __( 'Approve and Reply' ),
'reply' => __( 'Reply' ),
'warnQuickEdit' => __( "Are you sure you want to edit this comment?\nThe changes you made will be lost." ),
'docTitleComments' => __( 'Comments' ),
/* translators: %s: comments count */
'docTitleCommentsCount' => __( 'Comments (%s)' ),
) );
$scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), false, 1 );