diff --git a/features/language-core.feature b/features/language-core.feature index bcf81f9c7..e94f3a6ae 100644 --- a/features/language-core.feature +++ b/features/language-core.feature @@ -202,14 +202,14 @@ Feature: Manage translation files for a WordPress install When I try `wp language core install invalid_lang` Then STDERR should be: """ - Warning: Language 'invalid_lang' not found. - Error: No languages installed (1 failed). + Warning: Language 'invalid_lang' not available. """ And STDOUT should be: """ Language 'invalid_lang' not installed. + Success: Installed 0 of 1 languages (1 skipped). """ - And the return code should be 1 + And the return code should be 0 @require-wp-latest @require-php-5.6 @less-than-php-7.0 Scenario Outline: Core translation update diff --git a/features/language-plugin.feature b/features/language-plugin.feature index ca2662412..211a6de15 100644 --- a/features/language-plugin.feature +++ b/features/language-plugin.feature @@ -142,14 +142,14 @@ Feature: Manage translation files for a WordPress install When I try `wp language plugin install hello-dolly invalid_lang` Then STDERR should be: """ - Warning: Language 'invalid_lang' not found. - Error: No languages installed (1 failed). + Warning: Language 'invalid_lang' not available. """ And STDOUT should be: """ Language 'invalid_lang' not installed. + Success: Installed 0 of 1 languages (1 skipped). """ - And the return code should be 1 + And the return code should be 0 @require-wp-4.0 Scenario: Don't allow active language to be uninstalled diff --git a/features/language-theme.feature b/features/language-theme.feature index 175221d37..864747ac8 100644 --- a/features/language-theme.feature +++ b/features/language-theme.feature @@ -127,14 +127,14 @@ Feature: Manage translation files for a WordPress install When I try `wp language theme install twentyten invalid_lang` Then STDERR should be: """ - Warning: Language 'invalid_lang' not found. - Error: No languages installed (1 failed). + Warning: Language 'invalid_lang' not available. """ And STDOUT should be: """ Language 'invalid_lang' not installed. + Success: Installed 0 of 1 languages (1 skipped). """ - And the return code should be 1 + And the return code should be 0 @require-wp-4.0 Scenario: Don't allow active language to be uninstalled diff --git a/src/Core_Language_Command.php b/src/Core_Language_Command.php index f5c5b1e14..a861fec94 100644 --- a/src/Core_Language_Command.php +++ b/src/Core_Language_Command.php @@ -199,7 +199,13 @@ public function install( $args, $assoc_args ) { if ( is_wp_error( $response ) ) { \WP_CLI::warning( $response ); \WP_CLI::log( "Language '{$language_code}' not installed." ); - $errors++; + + // Skip if translation is not yet available. + if ( 'not_found' === $response->get_error_code() ) { + $skips++; + } else { + $errors++; + } } else { \WP_CLI::log( "Language '{$language_code}' installed." ); $successes++; diff --git a/src/Plugin_Language_Command.php b/src/Plugin_Language_Command.php index e5038a7e9..3509232d0 100644 --- a/src/Plugin_Language_Command.php +++ b/src/Plugin_Language_Command.php @@ -227,7 +227,13 @@ public function install( $args, $assoc_args ) { if ( is_wp_error( $response ) ) { \WP_CLI::warning( $response ); \WP_CLI::log( "Language '{$language_code}' not installed." ); - $errors++; + + // Skip if translation is not yet available. + if ( 'not_found' === $response->get_error_code() ) { + $skips++; + } else { + $errors++; + } } else { \WP_CLI::log( "Language '{$language_code}' installed." ); $successes++; diff --git a/src/Theme_Language_Command.php b/src/Theme_Language_Command.php index 5f4ce7a73..e44afd3ad 100644 --- a/src/Theme_Language_Command.php +++ b/src/Theme_Language_Command.php @@ -229,7 +229,13 @@ public function install( $args, $assoc_args ) { if ( is_wp_error( $response ) ) { \WP_CLI::warning( $response ); \WP_CLI::log( "Language '{$language_code}' not installed." ); - $errors++; + + // Skip if translation is not yet available. + if ( 'not_found' === $response->get_error_code() ) { + $skips++; + } else { + $errors++; + } } else { \WP_CLI::log( "Language '{$language_code}' installed." ); $successes++; diff --git a/src/WP_CLI/CommandWithTranslation.php b/src/WP_CLI/CommandWithTranslation.php index e84227e86..d31b0739f 100644 --- a/src/WP_CLI/CommandWithTranslation.php +++ b/src/WP_CLI/CommandWithTranslation.php @@ -218,7 +218,7 @@ protected function download_language_pack( $download, $slug = null ) { } if ( ! $translation_to_load ) { - return new \WP_Error( 'not_found', "Language '{$download}' not found." ); + return new \WP_Error( 'not_found', "Language '{$download}' not available." ); } $translation = (object) $translation;