From 8e94d33af707686e6503b8cfd7c356231c0721cd Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Mon, 7 Oct 2024 15:30:37 +0530 Subject: [PATCH] Add i18n support for status messages --- includes/Services/PluginUpgrader.php | 18 +++++++++--------- .../WPCLI/Handlers/InstallerCommandHandler.php | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/includes/Services/PluginUpgrader.php b/includes/Services/PluginUpgrader.php index fbd0999..b8ee133 100644 --- a/includes/Services/PluginUpgrader.php +++ b/includes/Services/PluginUpgrader.php @@ -68,7 +68,7 @@ public static function upgrade_extended_yith_plugin( $extended_slug ) { // Check if the extended plugin exists in the list if ( ! isset( $yith_plugins_to_upgrade[ $extended_slug ] ) ) { - $upgrade_status['message'] = 'Invalid extended plugin slug provided.'; + $upgrade_status['message'] = __( 'Invalid extended plugin slug provided.', 'wp-module-installer' ); return $upgrade_status; } @@ -80,12 +80,12 @@ public static function upgrade_extended_yith_plugin( $extended_slug ) { // Check if the extended plugin's status is unknown or not installed if ( $status_codes['unknown'] === $extended_status ) { - $upgrade_status['message'] = 'Could not determine the status of the extended plugin.'; + $upgrade_status['message'] = __( 'Could not determine the status of the extended plugin.', 'wp-module-installer' ); return $upgrade_status; } if ( $status_codes['not_installed'] === $extended_status ) { - $upgrade_status['message'] = 'Extended plugin is not installed.'; + $upgrade_status['message'] = __( 'Extended plugin is not installed.', 'wp-module-installer' ); return $upgrade_status; } @@ -94,20 +94,20 @@ public static function upgrade_extended_yith_plugin( $extended_slug ) { // Skip if the premium plugin is already active or installed if ( $status_codes['active'] === $premium_status || $status_codes['installed'] === $premium_status ) { - $upgrade_status['message'] = 'Premium plugin already installed or active: ' . $premium_slug; + $upgrade_status['message'] = __( 'Premium plugin already installed or active: ', 'wp-module-installer' ) . $premium_slug; return $upgrade_status; } // Provision a license for the premium version of the plugin $license_response = PLSUtility::provision_license( $premium_slug ); if ( is_wp_error( $license_response ) ) { - $upgrade_status['message'] = 'Failed to provision license for: ' . $premium_slug; + $upgrade_status['message'] = __( 'Failed to provision license for: ', 'wp-module-installer' ) . $premium_slug; return $upgrade_status; } // Check if the download URL is present in the license response if ( empty( $license_response['downloadUrl'] ) ) { - $upgrade_status['message'] = 'Download URL is missing for premium plugin: ' . $premium_slug; + $upgrade_status['message'] = __( 'Download URL is missing for premium plugin: ', 'wp-module-installer' ) . $premium_slug; return $upgrade_status; } @@ -122,7 +122,7 @@ public static function upgrade_extended_yith_plugin( $extended_slug ) { // Attempt to install the premium plugin using the provided download URL, and activate it if needed $premium_install_status = PluginInstaller::install_from_zip( $license_response['downloadUrl'], $should_activate ); if ( is_wp_error( $premium_install_status ) ) { - $upgrade_status['message'] = 'Failed to install the premium plugin: ' . $premium_slug; + $upgrade_status['message'] = __( 'Failed to install the premium plugin: ', 'wp-module-installer' ) . $premium_slug; if ( $should_activate ) { PluginInstaller::activate( $extended_slug ); } @@ -131,12 +131,12 @@ public static function upgrade_extended_yith_plugin( $extended_slug ) { // Mark as successfully upgraded $upgrade_status['upgraded'] = true; - $upgrade_status['message'] = 'Successfully provisioned and installed: ' . $premium_slug; + $upgrade_status['message'] = __( 'Successfully provisioned and installed: ', 'wp-module-installer' ) . $premium_slug; // Attempt to uninstall the extended version of the plugin $uninstall_status = PluginUninstaller::uninstall( $extended_slug ); if ( is_wp_error( $uninstall_status ) ) { - $upgrade_status['message'] = 'Successfully installed the premium plugin, but there was an error uninstalling the extended plugin. Manual cleanup may be required.'; + $upgrade_status['message'] = __( 'Successfully installed the premium plugin, but there was an error uninstalling the extended plugin. Manual cleanup may be required.', 'wp-module-installer' ); return $upgrade_status; } diff --git a/includes/WPCLI/Handlers/InstallerCommandHandler.php b/includes/WPCLI/Handlers/InstallerCommandHandler.php index 7ddc5d5..3c21775 100644 --- a/includes/WPCLI/Handlers/InstallerCommandHandler.php +++ b/includes/WPCLI/Handlers/InstallerCommandHandler.php @@ -43,9 +43,9 @@ public function auto_upgrade_extended_yith_plugins() { } if ( $all_upgrades_successful ) { - WP_CLI::success( 'YITH plugin upgrade process completed successfully.' ); + WP_CLI::success( __( 'YITH plugin upgrade process completed successfully.', 'wp-module-installer' ) ); } else { - WP_CLI::error( 'YITH plugin upgrade process completed, but some upgrades failed. Please check the logs.' ); + WP_CLI::error( __( 'YITH plugin upgrade process completed, but some upgrades failed. Please check the logs.', 'wp-module-installer' ) ); } }