diff --git a/plugins/woocommerce/changelog/fix-connect-command-text b/plugins/woocommerce/changelog/fix-connect-command-text new file mode 100644 index 00000000000..84d976dcb84 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-connect-command-text @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Make connect text translatable, add application-password section URL diff --git a/plugins/woocommerce/includes/cli/class-wc-cli-com-command.php b/plugins/woocommerce/includes/cli/class-wc-cli-com-command.php index 7ee897c2b32..5f6f7b63144 100644 --- a/plugins/woocommerce/includes/cli/class-wc-cli-com-command.php +++ b/plugins/woocommerce/includes/cli/class-wc-cli-com-command.php @@ -16,6 +16,8 @@ if ( ! defined( 'ABSPATH' ) ) { * @package WooCommerce */ class WC_CLI_COM_Command { + const APPLICATION_PASSWORD_SECTION_URL = 'https://woocommerce.com/my-account/#application-passwords'; + /** * Registers a commands for managing WooCommerce.com extensions. */ @@ -110,12 +112,12 @@ class WC_CLI_COM_Command { */ public static function disconnect( array $args, array $assoc_args ) { if ( ! WC_Helper::is_site_connected() ) { - WP_CLI::error( 'Your store is not connected to WooCommerce.com. Run `wp wc com connect` command.' ); + WP_CLI::error( __( 'Your store is not connected to WooCommerce.com. Run `wp wc com connect` command.', 'woocommerce' ) ); } - WP_CLI::confirm( 'Are you sure you want to disconnect your store from WooCommerce.com?', $assoc_args ); + WP_CLI::confirm( __( 'Are you sure you want to disconnect your store from WooCommerce.com?', 'woocommerce' ), $assoc_args ); WC_Helper::disconnect(); - WP_CLI::success( 'You have successfully disconnected your store from WooCommerce.com' ); + WP_CLI::success( __( 'You have successfully disconnected your store from WooCommerce.com', 'woocommerce' ) ); } /** @@ -152,20 +154,21 @@ class WC_CLI_COM_Command { if ( $force ) { WC_Helper::disconnect(); } else { - WP_CLI::error( 'Your store is already connected.' ); + WP_CLI::error( __( 'Your store is already connected.', 'woocommerce' ) ); return; } } - // phpcs:ignore - // @todo add URL to application password section if ( empty( $password ) ) { - $password = self::ask( 'Connection password:' ); + // translators: %s is the URL for the application-password section in WooCommerce.com. + WP_CLI::log( sprintf( __( 'If you don\'t have an application password (not your account password), generate a password from %s', 'woocommerce' ), esc_url( self::APPLICATION_PASSWORD_SECTION_URL ) ) ); + $password = self::ask( __( 'Connection password:', 'woocommerce' ) ); } $password = sanitize_text_field( $password ); if ( empty( $password ) ) { - WP_CLI::error( 'Invalid password.' ); + // translators: %s is the URL for the application-password section in WooCommerce.com. + WP_CLI::error( sprintf( __( 'Invalid password. Generate a new one from %s.', 'woocommerce' ), esc_url( self::APPLICATION_PASSWORD_SECTION_URL ) ) ); } $auth = WC_Helper::connect_with_password( $password ); @@ -174,7 +177,7 @@ class WC_CLI_COM_Command { } if ( WC_Helper::is_site_connected() ) { - WP_CLI::success( 'Store connected successfully.' ); + WP_CLI::success( __( 'Store connected successfully.', 'woocommerce' ) ); } }