Skip to content

Commit 5c31681

Browse files
jehervekbrown9
andcommitted
[not verified] Sync Health Tests: make messages easier to translate (#15396)
* Sync Health Tests: make messages easier to translate Fixes #15379 I've also taken the opportunity to make the message with a number translatable differently depending on the number. * Add missing period Co-Authored-By: Kim Brown <[email protected]> Co-authored-by: Kim Brown <[email protected]>
1 parent 95d4b87 commit 5c31681

File tree

1 file changed

+70
-33
lines changed

1 file changed

+70
-33
lines changed

_inc/lib/debugger/class-jetpack-cxn-tests.php

Lines changed: 70 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,29 @@ protected function test__sync_health() {
548548
);
549549

550550
} elseif ( Sync_Health::get_status() === Sync_Health::STATUS_OUT_OF_SYNC ) {
551-
552-
// Sync has experienced Data Loss.
551+
/*
552+
* Sync has experienced Data Loss.
553+
*/
554+
555+
$description = '<p>';
556+
$description .= esc_html__( 'The information synced by Jetpack ensures that Jetpack Search, Related Posts and other features are aligned with your site’s current content.', 'jetpack' );
557+
$description .= '</p>';
558+
$description .= '<p>';
559+
$description .= sprintf(
560+
'<span class="dashicons fail"><span class="screen-reader-text">%1$s</span></span> ',
561+
esc_html__( 'Error', 'jetpack' )
562+
);
563+
$description .= wp_kses(
564+
__( 'Jetpack has detected an error while syncing your site. <strong>We recommend <a id="full_sync_request_link" href="#">a full sync</a> to align Jetpack with your site data.</strong>', 'jetpack' ),
565+
array(
566+
'a' => array(
567+
'id' => array(),
568+
'href' => array(),
569+
),
570+
'strong' => array(),
571+
)
572+
);
573+
$description .= '</p>';
553574

554575
return self::failing_test(
555576
array(
@@ -559,27 +580,42 @@ protected function test__sync_health() {
559580
'action' => 'https://jetpack.com/contact-support/',
560581
'action_label' => __( 'Contact Jetpack Support', 'jetpack' ),
561582
'short_description' => __( 'Jetpack has detected an error syncing your site.', 'jetpack' ),
562-
'long_description' => sprintf(
563-
'<p>%1$s</p><p><span class="dashicons fail"><span class="screen-reader-text">%2$s</span></span> %3$s<strong> %4$s <a id="full_sync_request_link" href="#">%5$s</a> %6$s</strong></p>',
564-
__( 'The information synced by Jetpack ensures that Jetpack Search, Related Posts and other features are aligned with your site’s current content.', 'jetpack' ),
565-
__( 'Error', 'jetpack' ),
566-
__( 'Jetpack has detected an error while syncing your site', 'jetpack' ), /* translators: screen reader text indicating a test failed */
567-
__( 'We recommend', 'jetpack' ),
568-
__( 'full sync', 'jetpack' ),
569-
__( 'to align Jetpack with your site data.', 'jetpack' )
570-
),
583+
'long_description' => $description,
571584
)
572585
);
573586

574587
} else {
575-
576588
// Get the Sync Queue.
577589
$sender = Sync_Sender::get_instance();
578590
$sync_queue = $sender->get_sync_queue();
579591

580592
// lag exceeds 5 minutes.
581593
if ( $sync_queue->lag() > 5 * MINUTE_IN_SECONDS ) {
582594

595+
$description = '<p>';
596+
$description .= esc_html__( 'The information synced by Jetpack ensures that Jetpack Search, Related Posts and other features are aligned with your site’s current content.', 'jetpack' );
597+
$description .= '</p>';
598+
$description .= '<p>';
599+
$description .= sprintf(
600+
'<span class="dashicons dashicons-clock" style="color: orange;"><span class="screen-reader-text">%1$s</span></span> ',
601+
/* translators: name, used to describe a clock icon. */
602+
esc_html__( 'Clock', 'jetpack' )
603+
);
604+
$description .= wp_kses(
605+
sprintf(
606+
/* translators: placeholder is a number of minutes. */
607+
_n(
608+
'Jetpack has identified a delay while syncing individual content updates. Certain features might be slower than usual, but this is only temporary while sync catches up with recent changes to your site. <strong>We’re seeing a current delay of %1$d minute.</strong>',
609+
'Jetpack has identified a delay while syncing individual content updates. Certain features might be slower than usual, but this is only temporary while sync catches up with recent changes to your site. <strong>We’re seeing a current delay of %1$d minutes.</strong>',
610+
intval( $sync_queue->lag() / MINUTE_IN_SECONDS ),
611+
'jetpack'
612+
),
613+
number_format_i18n( $sync_queue->lag() / MINUTE_IN_SECONDS )
614+
),
615+
array( 'strong' => array() )
616+
);
617+
$description .= '</p>';
618+
583619
return self::failing_test(
584620
array(
585621
'name' => $name,
@@ -588,15 +624,7 @@ protected function test__sync_health() {
588624
'action' => null,
589625
'action_label' => null,
590626
'short_description' => __( 'Jetpack is experiencing a delay syncing your site.', 'jetpack' ),
591-
'long_description' => sprintf(
592-
'<p>%1$s</p><p><span class="dashicons dashicons-clock" style="color: orange;"><span class="screen-reader-text">%2$s</span></span> %3$s <strong>%4$s %5$d %6$s</strong></p>',
593-
__( 'The information synced by Jetpack ensures that Jetpack Search, Related Posts and other features are aligned with your site’s current content.', 'jetpack' ),
594-
__( 'Clock', 'jetpack' ),
595-
__( 'Jetpack has identified a delay while syncing individual content updates. Certain features might be slower than usual, but this is only temporary while sync catches up with recent changes to your site.', 'jetpack' ), /* translators: screen reader text indicating a test failed */
596-
__( 'We’re seeing a current delay of', 'jetpack' ),
597-
intval( $sync_queue->lag() / MINUTE_IN_SECONDS ),
598-
__( 'minutes.', 'jetpack' )
599-
),
627+
'long_description' => $description,
600628
)
601629
);
602630

@@ -608,8 +636,27 @@ protected function test__sync_health() {
608636
}
609637
}
610638
} else {
639+
/*
640+
* Sync is disabled.
641+
*/
642+
643+
$description = '<p>';
644+
$description .= esc_html__( 'The information synced by Jetpack ensures that Jetpack Search, Related Posts and other features are aligned with your site’s current content.', 'jetpack' );
645+
$description .= '</p>';
646+
$description .= '<p>';
647+
$description .= __( 'Developers may enable / disable syncing using the Sync Settings API.', 'jetpack' );
648+
$description .= '</p>';
649+
$description .= '<p>';
650+
$description .= sprintf(
651+
'<span class="dashicons fail"><span class="screen-reader-text">%1$s</span></span> ',
652+
esc_html__( 'Error', 'jetpack' )
653+
);
654+
$description .= wp_kses(
655+
__( 'Jetpack Sync has been disabled on your site. Without it, certain Jetpack features will not work. <strong>We recommend enabling Sync.</strong>', 'jetpack' ),
656+
array( 'strong' => array() )
657+
);
658+
$description .= '</p>';
611659

612-
// Sync is disabled.
613660
return self::failing_test(
614661
array(
615662
'name' => $name,
@@ -618,17 +665,7 @@ protected function test__sync_health() {
618665
'action' => 'https://github.com/Automattic/jetpack/blob/master/packages/sync/src/class-settings.php',
619666
'action_label' => __( 'See Github for more on Sync Settings', 'jetpack' ),
620667
'short_description' => __( 'Jetpack Sync has been disabled on your site.', 'jetpack' ),
621-
'long_description' => sprintf(
622-
'<p>%1$s</p><p>%2$s</p><p><span class="dashicons fail"><span class="screen-reader-text">%3$s</span></span> %4$s<strong> %5$s</strong></p>',
623-
__( 'The information synced by Jetpack ensures that Jetpack Search, Related Posts and other features are aligned with your site’s current content.', 'jetpack' ),
624-
__( 'Developers may enable / disable syncing using the Sync Settings API.', 'jetpack' ), /* translators: screen reader text indicating a test failed */
625-
__( 'The information synced by Jetpack ensures that Jetpack Search, Related Posts and other features are aligned with your site’s current content.', 'jetpack' ),
626-
__( 'Developers may enable / disable syncing using the Sync Settings API.', 'jetpack' ),
627-
/* translators: screen reader text indicating a test failed */
628-
__( 'Error', 'jetpack' ),
629-
__( 'Jetpack Sync has been disabled on your site. Without it, certain Jetpack features will not work.', 'jetpack' ),
630-
__( 'We recommend enabling Sync.', 'jetpack' )
631-
),
668+
'long_description' => $description,
632669
)
633670
);
634671

0 commit comments

Comments
 (0)