From 9083a54ba0ae821f517511e148f6d6dc5c3e32c9 Mon Sep 17 00:00:00 2001 From: sarthaknagoshe2002 Date: Thu, 19 Dec 2024 23:22:46 +0530 Subject: [PATCH 1/3] Fix: update the logic to reduce concatenation --- .../block-library/src/query-total/index.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/query-total/index.php b/packages/block-library/src/query-total/index.php index 5a8ab76b5d1ef..f6569404ef3a9 100644 --- a/packages/block-library/src/query-total/index.php +++ b/packages/block-library/src/query-total/index.php @@ -43,16 +43,16 @@ function render_block_core_query_total( $attributes, $content, $block ) { $range_text = sprintf( /* translators: 1: Start index of posts, 2: Total number of posts */ __( 'Displaying %1$s of %2$s' ), - '' . $start . '', - '' . $max_rows . '' + $start, + $max_rows ); } else { $range_text = sprintf( /* translators: 1: Start index of posts, 2: End index of posts, 3: Total number of posts */ __( 'Displaying %1$s – %2$s of %3$s' ), - '' . $start . '', - '' . $end . '', - '' . $max_rows . '' + $start, + $end, + $max_rows ); } @@ -61,10 +61,12 @@ function render_block_core_query_total( $attributes, $content, $block ) { case 'total-results': default: + // translators: %d: Total number of posts. + $total_text = sprintf( _n( '%d result found', '%d results found', $max_rows ), $max_rows ); $output = sprintf( - '

%d %s

', - $max_rows, - _n( 'result found', 'results found', $max_rows ) + '

%s

', + $total_text, + ); break; } From b8fa212246c37c3b4c247d52942b3b6f20730a29 Mon Sep 17 00:00:00 2001 From: sarthaknagoshe2002 Date: Fri, 20 Dec 2024 00:07:22 +0530 Subject: [PATCH 2/3] Fix: use correct php standards --- packages/block-library/src/query-total/index.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/query-total/index.php b/packages/block-library/src/query-total/index.php index f6569404ef3a9..3d1f523fd2754 100644 --- a/packages/block-library/src/query-total/index.php +++ b/packages/block-library/src/query-total/index.php @@ -63,10 +63,9 @@ function render_block_core_query_total( $attributes, $content, $block ) { default: // translators: %d: Total number of posts. $total_text = sprintf( _n( '%d result found', '%d results found', $max_rows ), $max_rows ); - $output = sprintf( + $output = sprintf( '

%s

', - $total_text, - + $total_text ); break; } From 42b77bb45c10b4bd612f400ab39c5b1a67b6ce42 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 20 Dec 2024 09:54:16 +0100 Subject: [PATCH 3/3] Use slightly different translator comment --- packages/block-library/src/query-total/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/query-total/index.php b/packages/block-library/src/query-total/index.php index 3d1f523fd2754..c78d0498f634f 100644 --- a/packages/block-library/src/query-total/index.php +++ b/packages/block-library/src/query-total/index.php @@ -61,7 +61,7 @@ function render_block_core_query_total( $attributes, $content, $block ) { case 'total-results': default: - // translators: %d: Total number of posts. + // translators: %d: number of results. $total_text = sprintf( _n( '%d result found', '%d results found', $max_rows ), $max_rows ); $output = sprintf( '

%s

',