wp-cli / language-command

Installs, activates, and manages language packs.
MIT License
13 stars 21 forks source link

Support installing translations for all installed plugins/themes #64

Closed ocean90 closed 5 years ago

ocean90 commented 5 years ago

See #59.

ocean90 commented 5 years ago

@schlessera provided some feedback on Slack for this: https://wordpress.slack.com/archives/C02RP4T41/p1539759949000100

tldr; Consider using a table for the output which should make it easier to parse the result of each installation.

ocean90 commented 5 years ago

Current output is inspired by wp plugin update --all:

wp language plugin install --all de_DE de_CH ``` Warning: Language 'de_DE' not available. Language 'de_DE' for 'Airplane Mode' not installed. Warning: Language 'de_CH' not available. Language 'de_CH' for 'Airplane Mode' not installed. Downloading translation from https://downloads.wordpress.org/translation/plugin/akismet/4.0.3/de_DE.zip... Unpacking the update... Installing the latest version... Translation updated successfully. Language 'de_DE' for 'Akismet Anti-Spam' installed. Downloading translation from https://downloads.wordpress.org/translation/plugin/akismet/3.1.11/de_CH.zip... Unpacking the update... Installing the latest version... Translation updated successfully. Language 'de_CH' for 'Akismet Anti-Spam' installed. Language 'de_DE' for 'Classic Editor' already installed. .... Warning: Language 'de_CH' not available. Language 'de_CH' for 'WP Team List' not installed. Language 'de_DE' for 'WP Team List' already installed. Language 'de_CH' for 'WP Team List' already installed. Language 'de_DE' for 'WP Widget Disable' already installed. Language 'de_CH' for 'WP Widget Disable' already installed. +---------------------------------+--------+-------------------+ | name | locale | status | +---------------------------------+--------+-------------------+ | airplane-mode-master | de_DE | not available | | airplane-mode-master | de_CH | not available | | akismet | de_DE | installed | | akismet | de_CH | installed | | classic-editor | de_DE | already installed | | classic-editor | de_CH | not available | .... | rplus-wp-team-list-git | de_DE | not available | | rplus-wp-team-list-git | de_CH | not available | | wp-team-list | de_DE | already installed | | wp-team-list | de_CH | already installed | | wp-widget-disable | de_DE | already installed | | wp-widget-disable | de_CH | already installed | +---------------------------------+--------+-------------------+ Success: Installed 2 of 86 languages (84 skipped). ```
wp language plugin install --all de_DE --format=summary ``` Warning: Language 'de_DE' not available. Language 'de_DE' for 'Airplane Mode' not installed. Language 'de_DE' for 'Akismet Anti-Spam' already installed. Language 'de_DE' for 'Classic Editor' already installed. Warning: Language 'de_DE' not available. Language 'de_DE' for 'Core Control' not installed. Warning: Language 'de_DE' not available. Language 'de_DE' for 'CSS' not installed. .... Language 'de_DE' for 'WP Team List' not installed. Language 'de_DE' for 'WP Team List' already installed. Language 'de_DE' for 'WP Widget Disable' already installed. Success: Installed 0 of 43 languages (43 skipped). ```
wp language plugin install --all de_DE --format=json ``` [{"name":"airplane-mode-master","locale":"de_DE","status":"not available"},{"name":"akismet","locale":"de_DE","status":"already installed"},{"name":"classic-editor","locale":"de_DE","status":"already installed"},{"name":"core-control","locale":"de_DE","status":"not available"},{"name":"css","locale":"de_DE","status":"not available"},{"name":"debug-bar","locale":"de_DE","status":"not available"},{"name":"debug-bar-console","locale":"de_DE","status":"not available"},{"name":"debug-bar-transients","locale":"de_DE","status":"already installed"},{"name":"disable-privacy-tools","locale":"de_DE","status":"already installed"},{"name":"drafts-of-post-revisions","locale":"de_DE","status":"not available"},{"name":"dynamic-hostname","locale":"de_DE","status":"not available"},{"name":"genericond","locale":"de_DE","status":"not available"},{"name":"gutenberg-git","locale":"de_DE","status":"not available"},{"name":"gutenberg","locale":"de_DE","status":"already installed"},{"name":"gutenberg-testing","locale":"de_DE","status":"not available"},{"name":"test-plugin","locale":"de_DE","status":"not available"},{"name":"h2push","locale":"de_DE","status":"not available"},{"name":"members","locale":"de_DE","status":"already installed"},{"name":"ms-global-media","locale":"de_DE","status":"not available"},{"name":"o2-git","locale":"de_DE","status":"not available"},{"name":"parent-term-toggler","locale":"de_DE","status":"not available"},{"name":"polylang","locale":"de_DE","status":"already installed"},{"name":"preserve-editor-scroll-position","locale":"de_DE","status":"not available"},{"name":"public-post-preview-git","locale":"de_DE","status":"not available"},{"name":"public-post-preview","locale":"de_DE","status":"already installed"},{"name":"query-monitor","locale":"de_DE","status":"already installed"},{"name":"relax-comment-filters","locale":"de_DE","status":"not available"},{"name":"rest-post-likes","locale":"de_DE","status":"not available"},{"name":"rewrite-rules-inspector","locale":"de_DE","status":"not available"},{"name":"shiny-updates","locale":"de_DE","status":"not available"},{"name":"shortcode-ui","locale":"de_DE","status":"already installed"},{"name":"slack","locale":"de_DE","status":"not available"},{"name":"solr-power","locale":"de_DE","status":"not available"},{"name":"user-switching","locale":"de_DE","status":"already installed"},{"name":"woocommerce","locale":"de_DE","status":"already installed"},{"name":"wordpress-importer","locale":"de_DE","status":"already installed"},{"name":"wordpress-importer-git","locale":"de_DE","status":"not available"},{"name":"wp-feed-post-thumbnail","locale":"de_DE","status":"already installed"},{"name":"rest-api","locale":"de_DE","status":"not available"},{"name":"rest-api-oauth1","locale":"de_DE","status":"not available"},{"name":"rplus-wp-team-list-git","locale":"de_DE","status":"not available"},{"name":"wp-team-list","locale":"de_DE","status":"already installed"},{"name":"wp-widget-disable","locale":"de_DE","status":"already installed"}]% ```


Let me know what you think. If it's good I'm going to do the same for themes and add some tests.

ocean90 commented 5 years ago

(The command:language-core-install label should probably be removed as the PR only touches plugins and themes.)

schlessera commented 5 years ago

@ocean90 What do you think about combining these two in the "live status messages" (not the table):

Warning: Language 'de_CH' not available.
Language 'de_CH' for 'WP Team List' not installed.

This would then turn into this instead:

Warning: Language 'de_CH' for 'WP Team List' not available.

This already implies that it will not be installed.

Would this make it clearer, or does it worsen overall consistency?

schlessera commented 5 years ago

Otherwise, I like the current version and think this is good to go.

ocean90 commented 5 years ago

What do you think about combining these two in the "live status messages"

The output next to "Warning" is just one of the WP_Error messages which download_language_pack() can return. We could extend the changes from #69 to also adjust the logging but not sure if it's really worth since it would only cover one case. Maybe worth it's own issue/PR.