Skip to content

Commit

Permalink
Fix singular translation issues & accessibility improvements (#2119)
Browse files Browse the repository at this point in the history
* Fix PHPStan issue

* Add area labels to previous and next navigations on the Dashboard Widget

* Remove unnecessary translatable string

* Change singular translations on getPeriodDescription() function

* Add build files

* Used, Yoda conditions must be.

---------

Co-authored-by: Alex Cicovic <23142906+acicovic@users.noreply.github.com>
  • Loading branch information
vaurdan and acicovic authored Jan 16, 2024
1 parent d33d431 commit 3f08cf1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/content-helper/dashboard-widget.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'eb2c678672339effd351');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'bc8a9708da1acc75b14d');
2 changes: 1 addition & 1 deletion build/content-helper/dashboard-widget.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/content-helper/editor-sidebar.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '87b2ffe95f05776cd359');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'b23d9ca630bca23c9955');
4 changes: 2 additions & 2 deletions build/content-helper/editor-sidebar.js

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions src/content-helper/common/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,32 @@ export function getPeriodDescription(
/* eslint-disable @wordpress/valid-sprintf */
switch ( timeUnit ) {
case 'm':
if ( 1 === timeValue ) {
description = __( 'Last Minute', 'wp-parsely' );
break;
}
description = sprintf( /* translators: 1: Number of minutes */
_n( 'Last Minute', 'Last %1$d Minutes', timeValue, 'wp-parsely' ),
_n( 'Last %1$d Minute', 'Last %1$d Minutes', timeValue, 'wp-parsely' ),
timeValue
);
break;
case 'h':
if ( 1 === timeValue ) {
description = __( 'Last Hour', 'wp-parsely' );
break;
}
description = sprintf( /* translators: 1: Number of hours */
_n( 'Last Hour', 'Last %1$d Hours', timeValue, 'wp-parsely' ),
_n( 'Last %1$d Hour', 'Last %1$d Hours', timeValue, 'wp-parsely' ),
timeValue
);
break;
case 'd':
if ( 1 === timeValue ) {
description = __( 'Last Day', 'wp-parsely' );
break;
}
description = sprintf( /* translators: 1: Number of days */
_n( 'Last Day', 'Last %1$d Days', timeValue, 'wp-parsely' ),
_n( 'Last %1$d Day', 'Last %1$d Days', timeValue, 'wp-parsely' ),
timeValue
);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/content-helper/common/utils/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function PostListItemMetric(

return (
<span className="parsely-top-post-metric-data">
{ __( '-', 'wp-parsely' ) }
-
</span>
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/content-helper/dashboard-widget/components/top-posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export function TopPosts(): JSX.Element {
<button
className="parsely-top-posts-navigation-prev"
disabled={ page <= 1 }
aria-label={ __( 'Previous page', 'wp-parsely' ) }
onClick={ () => {
setPage( page - 1 );
Telemetry.trackEvent( 'dash_widget_navigation', {
Expand All @@ -205,6 +206,7 @@ export function TopPosts(): JSX.Element {
<button
className="parsely-top-posts-navigation-next"
disabled={ ! loading && posts.length < TOP_POSTS_DEFAULT_LIMIT }
aria-label={ __( 'Next page', 'wp-parsely' ) }
onClick={ () => {
setPage( page + 1 );
Telemetry.trackEvent( 'dash_widget_navigation', {
Expand Down

0 comments on commit 3f08cf1

Please sign in to comment.