From da6b908ad04e0da39552eb9b4faf43a5f920b02e Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Fri, 17 Feb 2023 10:29:01 +0200 Subject: [PATCH 1/2] i18n fixes --- .../src/components/block-ratings/stars.js | 4 ++-- .../components/downloadable-block-notice/index.js | 13 ++++++++----- packages/block-directory/src/store/actions.js | 2 +- packages/block-directory/src/store/test/actions.js | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/block-directory/src/components/block-ratings/stars.js b/packages/block-directory/src/components/block-ratings/stars.js index 21c64290201b27..804debf5f00c62 100644 --- a/packages/block-directory/src/components/block-ratings/stars.js +++ b/packages/block-directory/src/components/block-ratings/stars.js @@ -1,7 +1,7 @@ /** * WordPress dependencies */ -import { __, sprintf } from '@wordpress/i18n'; +import { _n, sprintf } from '@wordpress/i18n'; import { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons'; function Stars( { rating } ) { @@ -15,7 +15,7 @@ function Stars( { rating } ) { diff --git a/packages/block-directory/src/components/downloadable-block-notice/index.js b/packages/block-directory/src/components/downloadable-block-notice/index.js index 539c3d59e7152f..6c32bb4281fa8c 100644 --- a/packages/block-directory/src/components/downloadable-block-notice/index.js +++ b/packages/block-directory/src/components/downloadable-block-notice/index.js @@ -1,7 +1,7 @@ /** * WordPress dependencies */ -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; import { useSelect } from '@wordpress/data'; /** @@ -23,10 +23,13 @@ export const DownloadableBlockNotice = ( { block } ) => { return (
- { errorNotice.message } - { errorNotice.isFatal - ? ' ' + __( 'Try reloading the page.' ) - : null } + { errorNotice.isFatal && + sprintf( + /* translators: %s: Error message. */ + __( '%s Try reloading the page.' ), + errorNotice.message + ) } + { ! errorNotice.isFatal && errorNotice.message }
); diff --git a/packages/block-directory/src/store/actions.js b/packages/block-directory/src/store/actions.js index 6e8ec13002acb4..b90352687c26ab 100644 --- a/packages/block-directory/src/store/actions.js +++ b/packages/block-directory/src/store/actions.js @@ -135,7 +135,7 @@ export const installBlockType = registry.dispatch( noticesStore ).createInfoNotice( sprintf( // translators: %s is the block title. - __( 'Block %s installed and added.' ), + __( 'Block "%s" installed and added.' ), block.title ), { diff --git a/packages/block-directory/src/store/test/actions.js b/packages/block-directory/src/store/test/actions.js index 7a75fffcb63315..bf20d68c61a339 100644 --- a/packages/block-directory/src/store/test/actions.js +++ b/packages/block-directory/src/store/test/actions.js @@ -120,7 +120,7 @@ describe( 'actions', () => { // Check that notice was displayed. const notices = registry.select( noticesStore ).getNotices(); expect( notices ).toMatchObject( [ - { content: 'Block Test Block installed and added.' }, + { content: 'Block "Test Block" installed and added.' }, ] ); } ); @@ -156,7 +156,7 @@ describe( 'actions', () => { // Check that notice was displayed. const notices = registry.select( noticesStore ).getNotices(); expect( notices ).toMatchObject( [ - { content: 'Block Test Block installed and added.' }, + { content: 'Block "Test Block" installed and added.' }, ] ); } ); From 455eac90c73c2f867199cc4091364edaf841653b Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Mon, 20 Feb 2023 09:14:32 +0200 Subject: [PATCH 2/2] revert quotes changes --- packages/block-directory/src/store/actions.js | 2 +- packages/block-directory/src/store/test/actions.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/block-directory/src/store/actions.js b/packages/block-directory/src/store/actions.js index b90352687c26ab..6e8ec13002acb4 100644 --- a/packages/block-directory/src/store/actions.js +++ b/packages/block-directory/src/store/actions.js @@ -135,7 +135,7 @@ export const installBlockType = registry.dispatch( noticesStore ).createInfoNotice( sprintf( // translators: %s is the block title. - __( 'Block "%s" installed and added.' ), + __( 'Block %s installed and added.' ), block.title ), { diff --git a/packages/block-directory/src/store/test/actions.js b/packages/block-directory/src/store/test/actions.js index bf20d68c61a339..7a75fffcb63315 100644 --- a/packages/block-directory/src/store/test/actions.js +++ b/packages/block-directory/src/store/test/actions.js @@ -120,7 +120,7 @@ describe( 'actions', () => { // Check that notice was displayed. const notices = registry.select( noticesStore ).getNotices(); expect( notices ).toMatchObject( [ - { content: 'Block "Test Block" installed and added.' }, + { content: 'Block Test Block installed and added.' }, ] ); } ); @@ -156,7 +156,7 @@ describe( 'actions', () => { // Check that notice was displayed. const notices = registry.select( noticesStore ).getNotices(); expect( notices ).toMatchObject( [ - { content: 'Block "Test Block" installed and added.' }, + { content: 'Block Test Block installed and added.' }, ] ); } );