Site Health: i18n audit, take 2.
* Use `wp.i18n` to translate JavaScript strings. * Use `_n()` for proper plural forms support. Props TimothyBlynJacobs, ocean90, afercia. Fixes #46683. git-svn-id: https://develop.svn.wordpress.org/trunk@45178 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5021d218ef
commit
936db1b0e1
@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
jQuery( document ).ready( function( $ ) {
|
jQuery( document ).ready( function( $ ) {
|
||||||
|
|
||||||
|
var __ = wp.i18n.__,
|
||||||
|
_n = wp.i18n._n,
|
||||||
|
sprintf = wp.i18n.sprintf;
|
||||||
|
|
||||||
var data;
|
var data;
|
||||||
var clipboard = new ClipboardJS( '.site-health-copy-buttons .copy-button' );
|
var clipboard = new ClipboardJS( '.site-health-copy-buttons .copy-button' );
|
||||||
var isDebugTab = $( '.health-check-body.health-check-debug-tab' ).length;
|
var isDebugTab = $( '.health-check-body.health-check-debug-tab' ).length;
|
||||||
@ -17,7 +21,7 @@ jQuery( document ).ready( function( $ ) {
|
|||||||
var $wrapper = $( e.trigger ).closest( 'div' );
|
var $wrapper = $( e.trigger ).closest( 'div' );
|
||||||
$( '.success', $wrapper ).addClass( 'visible' );
|
$( '.success', $wrapper ).addClass( 'visible' );
|
||||||
|
|
||||||
wp.a11y.speak( SiteHealth.string.site_info_copied );
|
wp.a11y.speak( __( 'Site information has been added to your clipboard.' ) );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Accordion handling in various areas.
|
// Accordion handling in various areas.
|
||||||
@ -52,11 +56,24 @@ jQuery( document ).ready( function( $ ) {
|
|||||||
function AppendIssue( issue ) {
|
function AppendIssue( issue ) {
|
||||||
var template = wp.template( 'health-check-issue' ),
|
var template = wp.template( 'health-check-issue' ),
|
||||||
issueWrapper = $( '#health-check-issues-' + issue.status ),
|
issueWrapper = $( '#health-check-issues-' + issue.status ),
|
||||||
issueCounter = $( '.issue-count', issueWrapper );
|
heading;
|
||||||
|
|
||||||
SiteHealth.site_status.issues[ issue.status ]++;
|
SiteHealth.site_status.issues[ issue.status ]++;
|
||||||
|
|
||||||
issueCounter.text( SiteHealth.site_status.issues[ issue.status ] );
|
var count = SiteHealth.site_status.issues[ issue.status ];
|
||||||
|
|
||||||
|
if ( 'critical' === issue.status ) {
|
||||||
|
heading = sprintf( _n( '%s Critical issue', '%s Critical issues', count ), '<span class="issue-count">' + count + '</span>' );
|
||||||
|
} else if ( 'recommended' === issue.status ) {
|
||||||
|
heading = sprintf( _n( '%s Recommended improvement', '%s Recommended improvements', count ), '<span class="issue-count">' + count + '</span>' );
|
||||||
|
} else if ( 'good' === issue.status ) {
|
||||||
|
heading = sprintf( _n( '%s Item with no issues detected', '%s Items with no issues detected', count ), '<span class="issue-count">' + count + '</span>' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( heading ) {
|
||||||
|
$( '> h3', issueWrapper ).html( heading );
|
||||||
|
}
|
||||||
|
|
||||||
$( '.issues', '#health-check-issues-' + issue.status ).append( template( issue ) );
|
$( '.issues', '#health-check-issues-' + issue.status ).append( template( issue ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +145,9 @@ jQuery( document ).ready( function( $ ) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
wp.a11y.speak( SiteHealth.string.site_health_complete_screen_reader.replace( '%s', val + '%' ) );
|
// translators: %s: The percentage score for the tests.
|
||||||
|
var text = __( 'All site health tests have finished running. Your site scored %s, and the results are now available on the page.' );
|
||||||
|
wp.a11y.speak( sprintf( text, val + '%' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +240,7 @@ jQuery( document ).ready( function( $ ) {
|
|||||||
|
|
||||||
// After 3 seconds announce that we're still waiting for directory sizes.
|
// After 3 seconds announce that we're still waiting for directory sizes.
|
||||||
var timeout = window.setTimeout( function() {
|
var timeout = window.setTimeout( function() {
|
||||||
wp.a11y.speak( SiteHealth.string.please_wait );
|
wp.a11y.speak( __( 'Please wait...' ) );
|
||||||
}, 3000 );
|
}, 3000 );
|
||||||
|
|
||||||
$.post( {
|
$.post( {
|
||||||
@ -248,7 +267,7 @@ jQuery( document ).ready( function( $ ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.setTimeout( function() {
|
window.setTimeout( function() {
|
||||||
wp.a11y.speak( SiteHealth.string.site_health_complete );
|
wp.a11y.speak( __( 'All site health tests have finished running.' ) );
|
||||||
}, delay );
|
}, delay );
|
||||||
} else {
|
} else {
|
||||||
// Cancel the announcement.
|
// Cancel the announcement.
|
||||||
|
@ -46,17 +46,6 @@ class WP_Site_Health {
|
|||||||
|
|
||||||
$health_check_js_variables = array(
|
$health_check_js_variables = array(
|
||||||
'screen' => $screen->id,
|
'screen' => $screen->id,
|
||||||
'string' => array(
|
|
||||||
'please_wait' => __( 'Please wait...' ),
|
|
||||||
'copied' => __( 'Copied' ),
|
|
||||||
'running_tests' => __( 'Currently being tested...' ),
|
|
||||||
'site_health_complete' => __( 'All site health tests have finished running.' ),
|
|
||||||
'site_info_show_copy' => __( 'Show options for copying this information' ),
|
|
||||||
'site_info_hide_copy' => __( 'Hide options for copying this information' ),
|
|
||||||
// translators: %s: The percentage score for the tests.
|
|
||||||
'site_health_complete_screen_reader' => __( 'All site health tests have finished running. Your site scored %s, and the results are now available on the page.' ),
|
|
||||||
'site_info_copied' => __( 'Site information has been added to your clipboard.' ),
|
|
||||||
),
|
|
||||||
'nonce' => array(
|
'nonce' => array(
|
||||||
'site_status' => wp_create_nonce( 'health-check-site-status' ),
|
'site_status' => wp_create_nonce( 'health-check-site-status' ),
|
||||||
'site_status_result' => wp_create_nonce( 'health-check-site-status-result' ),
|
'site_status_result' => wp_create_nonce( 'health-check-site-status-result' ),
|
||||||
|
@ -91,7 +91,7 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
|||||||
|
|
||||||
<div class="site-health-issues-wrapper" id="health-check-issues-critical">
|
<div class="site-health-issues-wrapper" id="health-check-issues-critical">
|
||||||
<h3>
|
<h3>
|
||||||
<span class="issue-count">0</span> <?php _e( 'Critical issues' ); ?>
|
<?php printf( _n( '%s Critical issue', '%s Critical issues', 0 ), '<span class="issue-count">0</span>' ); ?>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div id="health-check-site-status-critical" class="health-check-accordion issues"></div>
|
<div id="health-check-site-status-critical" class="health-check-accordion issues"></div>
|
||||||
@ -99,7 +99,7 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
|||||||
|
|
||||||
<div class="site-health-issues-wrapper" id="health-check-issues-recommended">
|
<div class="site-health-issues-wrapper" id="health-check-issues-recommended">
|
||||||
<h3>
|
<h3>
|
||||||
<span class="issue-count">0</span> <?php _e( 'Recommended improvements' ); ?>
|
<?php printf( _n( '%s Recommended improvement', '%s Recommended improvements', 0 ), '<span class="issue-count">0</span>' ); ?>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div id="health-check-site-status-recommended" class="health-check-accordion issues"></div>
|
<div id="health-check-site-status-recommended" class="health-check-accordion issues"></div>
|
||||||
|
@ -1690,7 +1690,7 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
|
$scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-i18n' ), false, 1 );
|
||||||
|
|
||||||
$scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
|
$scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
|
||||||
did_action( 'init' ) && $scripts->localize(
|
did_action( 'init' ) && $scripts->localize(
|
||||||
|
Loading…
Reference in New Issue
Block a user