Skip to content

Commit

Permalink
My Jetpack: useInstallPlugins() hook- Fix translations to account for…
Browse files Browse the repository at this point in the history
… localization. (#41756)

* Separate the success message into 2 separate strings for translation.
  • Loading branch information
elliottprogrammer authored Feb 19, 2025
1 parent 3e2dc1a commit bcfa47e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ const useInstallPlugins = ( productSlugs: string | string[] ) => {
const { products, refetch } = useProducts( productIds );
const { createSuccessNotice } = useGlobalNotices();

const successMessageSingular = sprintf(
/* translators: %s is the name of a Jetpack plugin, i.e.- "VaultPress Backup" or "Boost" or "Social" or "Search" or "VideoPress", etc. */
__( '%s installed successfully!', 'jetpack-my-jetpack' ),
products[ 0 ]?.title
);
const successMessagePlural = __( 'Plugins installed successfully!', 'jetpack-my-jetpack' );
const successMessage = products?.length === 1 ? successMessageSingular : successMessagePlural;

const { mutate: install, isPending } = useSimpleMutation( {
name: QUERY_INSTALL_PRODUCT_KEY,
query: {
Expand All @@ -20,18 +28,12 @@ const useInstallPlugins = ( productSlugs: string | string[] ) => {
options: {
onSuccess: () => {
refetch().then( () => {
createSuccessNotice(
sprintf(
/* translators: %s is the word "Plugin" or "Pluigns" (singular or plural). */
__( '%s installed successfully!', 'jetpack-my-jetpack' ),
products?.length === 1 ? products[ 0 ].title : __( 'Plugins', 'jetpack-my-jetpack' )
)
);
createSuccessNotice( successMessage );
} );
},
},
errorMessage: sprintf(
// translators: %s is the Jetpack product name or comma seperated list of multiple Jetpack product names.
// translators: %s is the Jetpack plugin name or comma seperated list of multiple Jetpack plugin names.
__( 'There was a problem installing and activating %s.', 'jetpack-my-jetpack' ),
products?.map( product => product?.name ).join( ', ' )
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: My Jetpack: useInstallPlugins() hook: Updates translations to account for localizations.


0 comments on commit bcfa47e

Please sign in to comment.