Skip to content

Commit c74a781

Browse files
authored
Merge pull request #40 from wp-cli/39-update-individual
Enable updating languages for individual plugins and themes
2 parents f7eb7dc + 8129e3b commit c74a781

File tree

9 files changed

+312
-103
lines changed

9 files changed

+312
-103
lines changed

.github/settings.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ labels:
2626
color: c5def5
2727
- name: command:language-core-activate
2828
color: c5def5
29+
- name: command:language-core-is-installed
30+
color: c5def5
2931
- name: command:language-core-install
3032
color: c5def5
3133
- name: command:language-core-list
@@ -36,6 +38,8 @@ labels:
3638
color: c5def5
3739
- name: command:language-plugin
3840
color: c5def5
41+
- name: command:language-plugin-is-installed
42+
color: c5def5
3943
- name: command:language-plugin-install
4044
color: c5def5
4145
- name: command:language-plugin-list
@@ -46,6 +50,8 @@ labels:
4650
color: c5def5
4751
- name: command:language-theme
4852
color: c5def5
53+
- name: command:language-theme-is-installed
54+
color: c5def5
4955
- name: command:language-theme-install
5056
color: c5def5
5157
- name: command:language-theme-list

README.md

Lines changed: 87 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ wp language
2929
$ wp language core activate nl_NL
3030
Success: Language activated.
3131

32+
# Install the Dutch language pack for Twenty Seventeen.
33+
$ wp language theme install twentyseventeen nl_NL
34+
Success: Language installed.
35+
36+
# Install the Dutch language pack for Akismet.
37+
$ wp language plugin install akismet nl_NL
38+
Success: Language installed.
39+
3240

3341

3442
### wp language core
@@ -213,14 +221,12 @@ wp language core uninstall <language>...
213221

214222
### wp language core update
215223

216-
Updates installed languages.
224+
Updates installed languages for core.
217225

218226
~~~
219227
wp language core update [--dry-run]
220228
~~~
221229

222-
Updates installed languages for core.
223-
224230
**OPTIONS**
225231

226232
[--dry-run]
@@ -264,11 +270,36 @@ wp language plugin
264270

265271

266272

273+
### wp language plugin is-installed
274+
275+
Checks if a given language is installed.
276+
277+
~~~
278+
wp language plugin is-installed <plugin> <language>...
279+
~~~
280+
281+
Returns exit code 0 when installed, 1 when uninstalled.
282+
283+
**OPTIONS**
284+
285+
<plugin>
286+
Plugin to check for.
287+
288+
<language>...
289+
The language code to check.
290+
291+
**EXAMPLES**
292+
293+
# Check whether the German language is installed for Akismet; exit status 0 if installed, otherwise 1.
294+
$ wp language plugin is-installed akismet de_DE
295+
$ echo $?
296+
1
297+
267298

268299

269300
### wp language plugin install
270301

271-
Installs a given language.
302+
Installs a given language for a plugin.
272303

273304
~~~
274305
wp language plugin install <plugin> <language>...
@@ -286,15 +317,15 @@ Downloads the language pack from WordPress.org.
286317

287318
**EXAMPLES**
288319

289-
# Install the Japanese language.
290-
$ wp language core install ja
320+
# Install the Japanese language for Akismet.
321+
$ wp language plugin install akismet ja
291322
Success: Language installed.
292323

293324

294325

295326
### wp language plugin list
296327

297-
Lists all available languages.
328+
Lists all available languages for one or more plugins.
298329

299330
~~~
300331
wp language plugin list [<plugin>...] [--all] [--field=<field>] [--<field>=<value>] [--fields=<fields>] [--format=<format>]
@@ -359,7 +390,7 @@ These fields are optionally available:
359390

360391
### wp language plugin uninstall
361392

362-
Uninstalls a given language.
393+
Uninstalls a given language for a plugin.
363394

364395
~~~
365396
wp language plugin uninstall <plugin> <language>...
@@ -382,22 +413,26 @@ wp language plugin uninstall <plugin> <language>...
382413

383414
### wp language plugin update
384415

385-
Updates installed languages.
416+
Updates installed languages for one or more plugins.
386417

387418
~~~
388-
wp language plugin update [--dry-run]
419+
wp language plugin update [<plugin>...] [--all] [--dry-run]
389420
~~~
390421

391-
Updates installed languages for plugins.
392-
393422
**OPTIONS**
394423

424+
[<plugin>...]
425+
One or more plugins to update languages for.
426+
427+
[--all]
428+
If set, languages for all plugins will be updated.
429+
395430
[--dry-run]
396431
Preview which translations would be updated.
397432

398433
**EXAMPLES**
399434

400-
$ wp language plugin update
435+
$ wp language plugin update --all
401436
Updating 'Japanese' translation for Akismet 3.1.11...
402437
Downloading translation from https://downloads.wordpress.org/translation/plugin/akismet/3.1.11/ja.zip...
403438
Translation updated successfully.
@@ -433,11 +468,36 @@ wp language theme
433468

434469

435470

471+
### wp language theme is-installed
472+
473+
Checks if a given language is installed.
474+
475+
~~~
476+
wp language theme is-installed <theme> <language>...
477+
~~~
478+
479+
Returns exit code 0 when installed, 1 when uninstalled.
480+
481+
**OPTIONS**
482+
483+
<theme>
484+
Theme to check for.
485+
486+
<language>...
487+
The language code to check.
488+
489+
**EXAMPLES**
490+
491+
# Check whether the German language is installed for Twenty Seventeen; exit status 0 if installed, otherwise 1.
492+
$ wp language theme is-installed twentyseventeen de_DE
493+
$ echo $?
494+
1
495+
436496

437497

438498
### wp language theme install
439499

440-
Installs a given language.
500+
Installs a given language for a theme.
441501

442502
~~~
443503
wp language theme install <theme> <language>...
@@ -455,15 +515,15 @@ Downloads the language pack from WordPress.org.
455515

456516
**EXAMPLES**
457517

458-
# Install the Japanese language.
459-
$ wp language core install ja
518+
# Install the Japanese language for Twenty Seventeen.
519+
$ wp language theme install twentyseventeen ja
460520
Success: Language installed.
461521

462522

463523

464524
### wp language theme list
465525

466-
Lists all available languages.
526+
Lists all available languages for one or more themes.
467527

468528
~~~
469529
wp language theme list [<theme>...] [--all] [--field=<field>] [--<field>=<value>] [--fields=<fields>] [--format=<format>]
@@ -528,7 +588,7 @@ These fields are optionally available:
528588

529589
### wp language theme uninstall
530590

531-
Uninstalls a given language.
591+
Uninstalls a given language for a theme.
532592

533593
~~~
534594
wp language theme uninstall <theme> <language>...
@@ -551,22 +611,26 @@ wp language theme uninstall <theme> <language>...
551611

552612
### wp language theme update
553613

554-
Updates installed languages.
614+
Updates installed languages for one or more themes.
555615

556616
~~~
557-
wp language theme update [--dry-run]
617+
wp language theme update [<plugin>...] [--all] [--dry-run]
558618
~~~
559619

560-
Updates installed languages for themes.
561-
562620
**OPTIONS**
563621

622+
[<plugin>...]
623+
One or more plugins to update languages for.
624+
625+
[--all]
626+
If set, languages for all themes will be updated.
627+
564628
[--dry-run]
565629
Preview which translations would be updated.
566630

567631
**EXAMPLES**
568632

569-
$ wp language theme update
633+
$ wp language theme update --all
570634
Updating 'Japanese' translation for Twenty Fifteen 1.5...
571635
Downloading translation from https://downloads.wordpress.org/translation/theme/twentyfifteen/1.5/ja.zip...
572636
Translation updated successfully.

features/language-core.feature

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ Feature: Manage translation files for a WordPress install
9292
| en_GB | English (UK) | none |
9393
| ja | Japanese | none |
9494

95-
When I run `wp language core update --dry-run`
96-
Then save STDOUT 'Found (\d+) translation updates that would be processed' as {UPDATES}
97-
9895
When I run `wp language core update`
9996
Then STDOUT should contain:
10097
"""

features/language-plugin.feature

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Feature: Manage translation files for a WordPress install
8585
| en_US | English (United States) | none |
8686
| en_GB | English (UK) | none |
8787

88-
When I run `wp language plugin update`
88+
When I run `wp language plugin update --all`
8989
Then STDOUT should contain:
9090
"""
9191
Success: Translations are up to date.
@@ -183,9 +183,42 @@ Feature: Manage translation files for a WordPress install
183183
"""
184184
And STDOUT should be empty
185185

186+
When I try `wp language plugin update`
187+
Then the return code should be 1
188+
And STDERR should be:
189+
"""
190+
Error: Please specify one or more plugins, or use --all.
191+
"""
192+
And STDOUT should be empty
193+
186194
Given an empty {PLUGIN_DIR} directory
187195
When I run `wp language plugin list --all`
188196
Then STDOUT should be:
189197
"""
190198
Success: No plugins installed.
191199
"""
200+
201+
When I run `wp language plugin update --all`
202+
Then STDOUT should be:
203+
"""
204+
Success: No plugins installed.
205+
"""
206+
207+
@require-wp-4.0
208+
Scenario: Ensure correct language is installed for plugin version
209+
Given a WP install
210+
And an empty cache
211+
And I run `wp plugin install akismet --version=3.2 --force`
212+
213+
When I run `wp language plugin install akismet de_DE_formal`
214+
Then STDOUT should contain:
215+
"""
216+
Downloading translation from https://downloads.wordpress.org/translation/plugin/akismet/3.2/de_DE_formal.zip
217+
"""
218+
219+
When I run `wp plugin install akismet --version=4.0 --force`
220+
And I run `wp language plugin update akismet`
221+
Then STDOUT should contain:
222+
"""
223+
Downloading translation from https://downloads.wordpress.org/translation/plugin/akismet/4.0/de_DE_formal.zip
224+
"""

features/language-theme.feature

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Feature: Manage translation files for a WordPress install
8484
| en_GB | English (UK) | none |
8585
| en_US | English (United States) | none |
8686

87-
When I run `wp language theme update`
87+
When I run `wp language theme update --all`
8888
Then STDOUT should contain:
8989
"""
9090
Success: Translations are up to date.
@@ -168,9 +168,42 @@ Feature: Manage translation files for a WordPress install
168168
"""
169169
And STDOUT should be empty
170170

171+
When I try `wp language theme update`
172+
Then the return code should be 1
173+
And STDERR should be:
174+
"""
175+
Error: Please specify one or more themes, or use --all.
176+
"""
177+
And STDOUT should be empty
178+
171179
Given an empty {THEME_DIR} directory
172180
When I run `wp language theme list --all`
173181
Then STDOUT should be:
174182
"""
175183
Success: No themes installed.
176184
"""
185+
186+
When I run `wp language theme update --all`
187+
Then STDOUT should be:
188+
"""
189+
Success: No themes installed.
190+
"""
191+
192+
@require-wp-4.0
193+
Scenario: Ensure correct language is installed for theme version
194+
Given a WP install
195+
And an empty cache
196+
And I run `wp theme install twentyseventeen --version=1.0 --force`
197+
198+
When I run `wp language theme install twentyseventeen de_DE`
199+
Then STDOUT should contain:
200+
"""
201+
Downloading translation from https://downloads.wordpress.org/translation/theme/twentyseventeen/1.0/de_DE.zip
202+
"""
203+
204+
When I run `wp theme install twentyseventeen --version=1.6 --force`
205+
And I run `wp language theme update twentyseventeen`
206+
Then STDOUT should contain:
207+
"""
208+
Downloading translation from https://downloads.wordpress.org/translation/theme/twentyseventeen/1.6/de_DE.zip
209+
"""

src/Core_Language_Command.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ public function uninstall( $args, $assoc_args ) {
273273
}
274274

275275
/**
276-
* Updates installed languages.
277-
*
278276
* Updates installed languages for core.
279277
*
280278
* ## OPTIONS
@@ -288,7 +286,7 @@ public function uninstall( $args, $assoc_args ) {
288286
* Updating 'Japanese' translation for WordPress 4.9.2...
289287
* Downloading translation from https://downloads.wordpress.org/translation/core/4.9.2/ja.zip...
290288
* Translation updated successfully.
291-
* Success: Updated 1/1 translations.
289+
* Success: Updated 1/1 translation.
292290
*
293291
* @subcommand update
294292
*/

0 commit comments

Comments
 (0)