From 849ee8da92f1b96de67dc6dc70e17a54ed8203c9 Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:09:03 +0900 Subject: [PATCH] DataViews: Fix text in action for setting site home page (#67787) Co-authored-by: t-hamano Co-authored-by: mikachan --- .../post-actions/set-as-homepage.js | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/editor/src/components/post-actions/set-as-homepage.js b/packages/editor/src/components/post-actions/set-as-homepage.js index 70bdeeeefe70f..0252c84e3ab3f 100644 --- a/packages/editor/src/components/post-actions/set-as-homepage.js +++ b/packages/editor/src/components/post-actions/set-as-homepage.js @@ -47,9 +47,6 @@ const SetAsHomepageModal = ( { items, closeModal } ) => { }; } ); - const currentHomePageTitle = currentHomePage - ? getItemTitle( currentHomePage ) - : ''; const { saveEditedEntityRecord, saveEntityRecord } = useDispatch( coreStore ); @@ -89,23 +86,25 @@ const SetAsHomepageModal = ( { items, closeModal } ) => { } } - const modalWarning = - 'posts' === showOnFront - ? __( - 'This will replace the current homepage which is set to display latest posts.' - ) - : sprintf( - // translators: %s: title of the current home page. - __( 'This will replace the current homepage: "%s"' ), - currentHomePageTitle - ); + let modalWarning = ''; + if ( 'posts' === showOnFront ) { + modalWarning = __( + 'This will replace the current homepage which is set to display latest posts.' + ); + } else if ( currentHomePage ) { + modalWarning = sprintf( + // translators: %s: title of the current home page. + __( 'This will replace the current homepage: "%s"' ), + getItemTitle( currentHomePage ) + ); + } const modalText = sprintf( // translators: %1$s: title of the page to be set as the homepage, %2$s: homepage replacement warning message. __( 'Set "%1$s" as the site homepage? %2$s' ), pageTitle, modalWarning - ); + ).trim(); // translators: Button label to confirm setting the specified page as the homepage. const modalButtonLabel = __( 'Set homepage' );