Skip to content

Enable updating languages for individual plugins and themes#40

Merged
schlessera merged 17 commits intomasterfrom
39-update-individual
Aug 5, 2018
Merged

Enable updating languages for individual plugins and themes#40
schlessera merged 17 commits intomasterfrom
39-update-individual

Conversation

@swissspidy
Copy link
Copy Markdown
Member

@swissspidy swissspidy commented Aug 2, 2018

Fixes #39.

This means that for updating all translations on a site, one has to run the following commands

wp language core update
wp language plugin update --all
wp language theme update --all

Additional thoughts:

\WP_CLI\CommandWithTranslation::get_translation_updates() uses the list of available locales for the the plugin and theme update checks to tell WordPress.org which locales are already installed.

An example scenario can be that de_DE is installed for core, but only ja and en_GB for akismet. The update command (and perhaps even the list command?) might show false information in that case, indicating that no update for ja and en_GB is available, because only de_DE is checked. I haven't properly tested that though.

To fix this, instead of passing all installed locales we could try passing all possible locales that can be installed (using \WP_CLI\CommandWithTranslation::get_all_languages()).

Background: \WP_CLI\CommandWithTranslation::update() calls \WP_CLI\CommandWithTranslation::get_translation_updates() which in turn calls \WP_CLI\CommandWithTranslation::get_installed_languages(). It does so without passing the plugin/theme slug (relying on the default instead, which is default).

This is something we might want to explore in a separate issue.

@schlessera schlessera added command:language-plugin-update Related to 'language plugin update' command command:language-theme-update Related to 'language theme update' command labels Aug 2, 2018
@swissspidy
Copy link
Copy Markdown
Member Author

The tests for wp language core update --dry-run don't seem to want to pass anymore, but otherwise we're getting there...

1f917fc was basically the biggest needed change so far.

I'm a bit unsure about my note regarding the available locales above as I don't have proof of that yet.

$translation = (object) reset( $translation );
// Only preview which translations would be updated.
if ( Utils\get_flag_value( $assoc_args, 'dry-run' ) ) {
WP_CLI::line( sprintf( 'Found %d translation updates that would be processed:', count( $updates ) ) );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a count per type?

This would mean the --dry-run check and early return needs to happen after the foreach loop that builds the $updates_per_type array.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah I somehow moved this from after the loop to before 🤦‍♀️ ☕️

@swissspidy swissspidy changed the title [WIP] Enable updating languages for individual plugins and themes Enable updating languages for individual plugins and themes Aug 5, 2018
@swissspidy
Copy link
Copy Markdown
Member Author

I think this is good to go for now.

I want to test this a bit in the wild in order to better determine what doesn't work, what needs tests, etc.

@schlessera schlessera added this to the 1.0.8 milestone Aug 5, 2018
@schlessera schlessera merged commit c74a781 into master Aug 5, 2018
@schlessera schlessera deleted the 39-update-individual branch August 5, 2018 16:31
schlessera added a commit that referenced this pull request Jan 5, 2022
Enable updating languages for individual plugins and themes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:language-plugin-update Related to 'language plugin update' command command:language-theme-update Related to 'language theme update' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow updating language packs for individual plugins and themes

2 participants