From 8147ecbd5f476fd163c696e130dec5c28e7e064f Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Tue, 10 Dec 2024 19:35:12 +0900 Subject: [PATCH] DataViews: Fix text in action for setting site home page --- .../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' );