From 979b6d39ba145b74da14d5cca4ff417a83f992c5 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Thu, 7 May 2020 13:21:47 -0400 Subject: [PATCH] Block Directory: Remove the author rating when none exist A `0` rating means there have been no reviews submitted, so we can omit this string. --- .../downloadable-block-author-info/index.js | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/block-directory/src/components/downloadable-block-author-info/index.js b/packages/block-directory/src/components/downloadable-block-author-info/index.js index d848a6dc8fd31..369aee6a4f9f3 100644 --- a/packages/block-directory/src/components/downloadable-block-author-info/index.js +++ b/packages/block-directory/src/components/downloadable-block-author-info/index.js @@ -19,16 +19,26 @@ function DownloadableBlockAuthorInfo( { ) } - { sprintf( - /* translators: 1: number of blocks. 2: average rating. */ - _n( - 'This author has %1$d block, with an average rating of %2$d.', - 'This author has %1$d blocks, with an average rating of %2$d.', - authorBlockCount - ), - authorBlockCount, - authorBlockRating - ) } + { authorBlockRating > 0 + ? sprintf( + /* translators: 1: number of blocks. 2: average rating. */ + _n( + 'This author has %1$d block, with an average rating of %2$d.', + 'This author has %1$d blocks, with an average rating of %2$d.', + authorBlockCount + ), + authorBlockCount, + authorBlockRating + ) + : sprintf( + /* translators: 1: number of blocks. */ + _n( + 'This author has %1$d block.', + 'This author has %1$d blocks.', + authorBlockCount + ), + authorBlockCount + ) } );