Allow to install language packs for all plugins
mahnunchik opened this issue · 8 comments
Allow to install language packs for all plugins.
Expected commands:
$ wp language plugin install --all ru_RU
OR
$ $ wp language plugin install ru_RU --all
Current behaviour:
$ wp language plugin install --all ru_RU
usage: wp language plugin install <plugin> <language>...
A solution to this is wp plugin list --field=name | xargs -I % wp language plugin install % ru_RU
but I think having a single command could be faster.
I'd be fine with an --all
flag, given the convenience factor.
I was looking at the update command which also supports the --all
argument. The difference is that it that the update command doesn't use locales, it updates all installed translations. In general, the --all
is a bit ambiguous in this case. You could expect that it's for "all locales/languages" since it's the language command.
Anyway, we can't use the same for the installation command and I guess we want to avoid WP_CLI::launch_self()
? Any other hints?
Noting that we should do the same for themes, of course.
We could split the install()
method into install_single()
and install_multiple()
. The first one would be the same as the current install()
method. The latter would loop over all plugins/themes. This would allow us to add proper logging output like "Installing 'de_DE' translation for Plugin Name 1.0...". Something which is currently missing as noticed in one of our deploy tools.
We could split the
install()
method intoinstall_single()
andinstall_multiple()
I tried this in 33c0986. The output may look like this:
$ wpd language plugin install --all fr_FR
Warning: Language 'fr_FR' not found.
Language 'fr_FR' for 'Airplane Mode' not installed.
Language 'fr_FR' for 'Akismet Anti-Spam' already installed.
Warning: Language 'fr_FR' not found.
Language 'fr_FR' for 'Core Control' not installed.
Downloading translation from https://downloads.wordpress.org/translation/plugin/gutenberg/1.7.0/fr_FR.zip...
Unpacking the update...
Installing the latest version...
Translation updated successfully.
Language 'fr_FR' for 'Gutenberg' installed.
....
Error: Only installed 1 of 42 languages (38 failed, 3 skipped).
A solution to this is
wp plugin list --field=name | xargs -I % wp language plugin install % ru_RU
but I think having a single command could be faster.
A bit more complex solution that only install when language exists:
wp language plugin list --all --fields=plugin,language | grep es_ES | cut -f 1 | xargs -I % wp language plugin install % es_ES
wp language theme list --all --fields=theme,language | grep es_ES | cut -f 1 | xargs -I % wp language theme install % es_ES
But I would like to have a command wp language install --all es_ES
or wp language update --all es_ES
with the same behavior as "Update translations" in the WP dashboard that update translations for all.
@ocean90 v2.0.2 was tagged, I'll push an update to wp-cli-bundle
to trigger a new nightly.