Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions features/language-plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,35 @@ Feature: Manage plugin translation files for a WordPress install
# If the fix is working, installed languages should be detected via text domain
When I run `wp language plugin is-installed test-plugin de_DE`
Then the return code should be 0

@require-wp-4.0
Scenario: Update a translation that the translations API does not list
Given a WP install
And an empty cache

When I run `wp plugin install akismet --version=3.2 --force`
Then STDERR should be empty

When I run `wp language plugin install akismet de_DE`
Then STDERR should be empty

When I run `wp plugin install akismet --version=4.0 --force`
Then STDERR should be empty

# The update check still offers the de_DE language pack, but the translations
# API no longer reports de_DE for the installed version, so there is no
# english_name to fall back on.
And that HTTP requests to api.wordpress.org/translations/plugins/1.0/ will respond with:
"""
HTTP/1.1 200
Content-Type: application/json

{"translations":[]}
"""

When I run `wp language plugin update akismet`
Then STDOUT should contain:
"""
Updating 'de_DE' translation for Akismet
"""
And STDERR should be empty
13 changes: 6 additions & 7 deletions src/WP_CLI/CommandWithTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,12 @@ public function update( $args, $assoc_args ) {
$translation = wp_list_filter( $all_languages, array( 'language' => $update->language ) );
$translation = (object) reset( $translation );

$update->Type = ucfirst( $update->type );
$update->Name = $name;
$update->Version = $update->version;

if ( isset( $translation->english_name ) ) {
$update->Language = $translation->english_name;
}
$update->Type = ucfirst( $update->type );
$update->Name = $name;
$update->Version = $update->version;
$update->Language = isset( $translation->english_name )
? $translation->english_name
: $update->language;

if ( ! isset( $updates_per_type[ $update->type ] ) ) {
$updates_per_type[ $update->type ] = array();
Expand Down