Skip to content

Commit 46cc31e

Browse files
authored
Merge branch 'main' into fix/84
2 parents d38e2df + adfd1ec commit 46cc31e

13 files changed

Lines changed: 289 additions & 171 deletions

‎.github/workflows/testing.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Testing
22

33
on:
4+
workflow_dispatch:
45
pull_request:
56
push:
67
branches:

‎README.md‎

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Installs a given language.
150150
wp language core install <language>... [--activate]
151151
~~~
152152

153-
Downloads the language pack from WordPress.org.
153+
Downloads the language pack from WordPress.org. Find your language code at: https://translate.wordpress.org/
154154

155155
**OPTIONS**
156156

@@ -162,14 +162,14 @@ Downloads the language pack from WordPress.org.
162162

163163
**EXAMPLES**
164164

165-
# Install the Japanese language.
166-
$ wp language core install ja
167-
Downloading translation from https://downloads.wordpress.org/translation/core/6.4.3/ja.zip...
165+
# Install the Brazilian Portuguese language.
166+
$ wp language core install pt_BR
167+
Downloading translation from https://downloads.wordpress.org/translation/core/6.5/pt_BR.zip...
168168
Unpacking the update...
169169
Installing the latest version...
170170
Removing the old version of the translation...
171171
Translation updated successfully.
172-
Language 'ja' installed.
172+
Language 'pt_BR' installed.
173173
Success: Installed 1 of 1 languages.
174174

175175

@@ -201,6 +201,7 @@ wp language core list [--field=<field>] [--<field>=<value>] [--fields=<fields>]
201201
- table
202202
- csv
203203
- json
204+
- count
204205
---
205206

206207
**AVAILABLE FIELDS**
@@ -418,6 +419,7 @@ wp language plugin list [<plugin>...] [--all] [--field=<field>] [--<field>=<valu
418419
- table
419420
- csv
420421
- json
422+
- count
421423
---
422424

423425
**AVAILABLE FIELDS**
@@ -664,6 +666,7 @@ wp language theme list [<theme>...] [--all] [--field=<field>] [--<field>=<value>
664666
- table
665667
- csv
666668
- json
669+
- count
667670
---
668671

669672
**AVAILABLE FIELDS**
@@ -763,6 +766,26 @@ wp language theme update [<theme>...] [--all] [--dry-run]
763766
Translation updated successfully.
764767
Success: Updated 1/1 translation.
765768

769+
770+
771+
### wp site switch-language
772+
773+
Activates a given language.
774+
775+
~~~
776+
wp site switch-language <language>
777+
~~~
778+
779+
**OPTIONS**
780+
781+
<language>
782+
Language code to activate.
783+
784+
**EXAMPLES**
785+
786+
$ wp site switch-language ja
787+
Success: Language activated.
788+
766789
## Installing
767790

768791
This package is included with WP-CLI itself, no additional installation necessary.

‎composer.json‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@
1212
}
1313
],
1414
"require": {
15-
"wp-cli/wp-cli": "^2.5"
15+
"wp-cli/wp-cli": "^2.12"
1616
},
1717
"require-dev": {
1818
"wp-cli/db-command": "^1.3 || ^2",
1919
"wp-cli/entity-command": "^1.3 || ^2",
2020
"wp-cli/extension-command": "^1.2 || ^2",
21-
"wp-cli/wp-cli-tests": "^4"
21+
"wp-cli/wp-cli-tests": "^5"
2222
},
2323
"config": {
2424
"process-timeout": 7200,
2525
"sort-packages": true,
2626
"allow-plugins": {
2727
"dealerdirect/phpcodesniffer-composer-installer": true,
28-
"johnpbloch/wordpress-core-installer": true
29-
}
28+
"johnpbloch/wordpress-core-installer": true,
29+
"phpstan/extension-installer": true
30+
},
31+
"lock": false
3032
},
3133
"extra": {
3234
"branch-alias": {
@@ -53,7 +55,8 @@
5355
"language theme install",
5456
"language theme list",
5557
"language theme uninstall",
56-
"language theme update"
58+
"language theme update",
59+
"site switch-language"
5760
]
5861
},
5962
"autoload": {
@@ -71,12 +74,14 @@
7174
"behat-rerun": "rerun-behat-tests",
7275
"lint": "run-linter-tests",
7376
"phpcs": "run-phpcs-tests",
77+
"phpstan": "run-phpstan-tests",
7478
"phpcbf": "run-phpcbf-cleanup",
7579
"phpunit": "run-php-unit-tests",
7680
"prepare-tests": "install-package-tests",
7781
"test": [
7882
"@lint",
7983
"@phpcs",
84+
"@phpstan",
8085
"@phpunit",
8186
"@behat"
8287
]

‎features/language-core.feature‎

Lines changed: 51 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Feature: Manage translation files for a WordPress install
1+
Feature: Manage core translation files for a WordPress install
22

33
@require-wp-4.0
44
Scenario: Core translation CRUD
@@ -178,14 +178,14 @@ Feature: Manage translation files for a WordPress install
178178
"""
179179

180180
When I run `wp language core uninstall en_CA ja`
181-
Then the wp-content/languages/admin-en_CA.po file should not exist
182-
And the wp-content/languages/en_CA.po file should not exist
183-
And the wp-content/languages/en_CA.l10n.php file should not exist
184-
And the wp-content/languages/admin-ja.po file should not exist
185-
And the wp-content/languages/ja.po file should not exist
186-
And the wp-content/languages/ja.l10n.php file should not exist
187-
And STDOUT should be:
188-
"""
181+
Then the wp-content/languages/admin-en_CA.po file should not exist
182+
And the wp-content/languages/en_CA.po file should not exist
183+
And the wp-content/languages/en_CA.l10n.php file should not exist
184+
And the wp-content/languages/admin-ja.po file should not exist
185+
And the wp-content/languages/ja.po file should not exist
186+
And the wp-content/languages/ja.l10n.php file should not exist
187+
And STDOUT should be:
188+
"""
189189
Success: Language uninstalled.
190190
Success: Language uninstalled.
191191
"""
@@ -220,78 +220,6 @@ Feature: Manage translation files for a WordPress install
220220
"""
221221
And the return code should be 0
222222

223-
# This test downgrades to older WP version. PHP restriction is added to avoid warnings in latest versions.
224-
@less-than-php-7.0
225-
Scenario Outline: Core translation update
226-
Given an empty directory
227-
And WP files
228-
And a database
229-
And I run `wp core download --version=<original> --force`
230-
And wp-config.php
231-
And I run `wp core install --url='localhost:8001' --title='Test' --admin_user=wpcli --admin_email=admin@example.com --admin_password=1`
232-
233-
When I run `wp language core list --fields=language,status,update`
234-
Then STDOUT should be a table containing rows:
235-
| language | status | update |
236-
| ar | uninstalled | none |
237-
| en_CA | uninstalled | none |
238-
| en_US | active | none |
239-
| ja | uninstalled | none |
240-
241-
When I run `wp language core install en_CA ja`
242-
Then the wp-content/languages/admin-en_CA.po file should exist
243-
And the wp-content/languages/en_CA.po file should exist
244-
And the wp-content/languages/admin-ja.po file should exist
245-
And the wp-content/languages/ja.po file should exist
246-
And STDOUT should contain:
247-
"""
248-
Success: Installed 2 of 2 languages.
249-
"""
250-
And STDERR should be empty
251-
252-
Given I try `wp core download --version=<update> --force`
253-
Then the return code should be 0
254-
And I run `wp core update-db`
255-
256-
When I run `wp language core list --fields=language,status,update`
257-
Then STDOUT should be a table containing rows:
258-
| language | status | update |
259-
| ar | uninstalled | none |
260-
| en_CA | installed | available |
261-
| en_US | active | none |
262-
| ja | installed | available |
263-
264-
When I run `wp language core update --dry-run`
265-
Then STDOUT should contain:
266-
"""
267-
Found 2 translation updates that would be processed
268-
"""
269-
And STDOUT should contain:
270-
"""
271-
Core
272-
"""
273-
And STDOUT should contain:
274-
"""
275-
WordPress
276-
"""
277-
And STDOUT should contain:
278-
"""
279-
<update>
280-
"""
281-
And STDOUT should contain:
282-
"""
283-
English (Canada)
284-
"""
285-
And STDOUT should contain:
286-
"""
287-
Japanese
288-
"""
289-
290-
Examples:
291-
| original | update |
292-
| 4.8 | 4.9 |
293-
| 4.0.1 | 4.2 |
294-
295223
@require-wp-6.0 @require-php-7.2
296224
Scenario Outline: Core translation update in newer versions
297225
Given an empty directory
@@ -360,8 +288,8 @@ Feature: Manage translation files for a WordPress install
360288

361289
Examples:
362290
| original | update |
363-
| 6.0 | 6.1 |
364-
| 6.1.1 | 6.2 |
291+
| 6.5 | 6.6 |
292+
| 6.6.1 | 6.7 |
365293

366294
@require-wp-4.0
367295
Scenario: Don't allow active language to be uninstalled
@@ -378,20 +306,20 @@ Feature: Manage translation files for a WordPress install
378306
And STDOUT should be empty
379307
And the return code should be 0
380308

381-
# This test downgrades to WordPress 5.4.1, but the SQLite plugin requires 6.0+
382-
@require-wp-4.0 @require-mysql
309+
# This test downgrades to WordPress 5.6.14, but the SQLite plugin requires 6.0+
310+
@require-wp-5.7 @require-mysql
383311
Scenario: Ensure correct language is installed for WP version
384312
Given a WP install
385313
And I try `wp theme install twentytwentyone`
386314
And I run `wp theme activate twentytwentyone`
387315
And an empty cache
388-
And I run `wp core download --version=4.5.3 --force`
316+
And I run `wp core download --version=5.6.14 --force`
389317

390318
# PHP 8.2+ will show a warning for old WordPress core version.
391319
When I try `wp language core install nl_NL`
392320
Then STDOUT should contain:
393321
"""
394-
Downloading translation from https://downloads.wordpress.org/translation/core/4.5.3
322+
Downloading translation from https://downloads.wordpress.org/translation/core/5.6.14
395323
"""
396324
And STDOUT should contain:
397325
"""
@@ -439,52 +367,52 @@ Feature: Manage translation files for a WordPress install
439367
Die aktuelle Version wird installiert
440368
"""
441369

442-
@require-wp-4.0
443-
Scenario: Show correct active language after switching
444-
Given a WP install
445-
And an empty cache
370+
@require-wp-4.0
371+
Scenario: Show correct active language after switching
372+
Given a WP install
373+
And an empty cache
446374

447-
When I try `wp language core is-installed en_US`
448-
Then the return code should be 0
375+
When I try `wp language core is-installed en_US`
376+
Then the return code should be 0
449377

450-
When I run `wp language core install de_DE`
451-
Then the wp-content/languages/admin-de_DE.po file should exist
452-
And the wp-content/languages/de_DE.po file should exist
453-
And STDOUT should contain:
378+
When I run `wp language core install de_DE`
379+
Then the wp-content/languages/admin-de_DE.po file should exist
380+
And the wp-content/languages/de_DE.po file should exist
381+
And STDOUT should contain:
454382
"""
455383
Success: Installed 1 of 1 languages.
456384
"""
457-
And STDERR should be empty
385+
And STDERR should be empty
458386

459-
When I try `wp language core is-installed de_DE`
460-
Then the return code should be 0
387+
When I try `wp language core is-installed de_DE`
388+
Then the return code should be 0
461389

462-
When I run `wp language core list --field=language --status=active`
463-
Then STDOUT should be:
390+
When I run `wp language core list --field=language --status=active`
391+
Then STDOUT should be:
464392
"""
465393
en_US
466394
"""
467395

468-
When I run `wp site switch-language de_DE`
469-
Then STDOUT should be:
396+
When I run `wp site switch-language de_DE`
397+
Then STDOUT should be:
470398
"""
471399
Success: Language activated.
472400
"""
473401

474-
When I run `wp language core list --field=language --status=active`
475-
Then STDOUT should be:
402+
When I run `wp language core list --field=language --status=active`
403+
Then STDOUT should be:
476404
"""
477405
de_DE
478406
"""
479407

480-
When I run `wp site switch-language en_US`
481-
Then STDOUT should be:
408+
When I run `wp site switch-language en_US`
409+
Then STDOUT should be:
482410
"""
483411
Success: Language activated.
484412
"""
485413

486-
When I run `wp language core list --field=language --status=active`
487-
Then STDOUT should be:
414+
When I run `wp language core list --field=language --status=active`
415+
Then STDOUT should be:
488416
"""
489417
en_US
490418
"""
@@ -535,3 +463,16 @@ Feature: Manage translation files for a WordPress install
535463
"""
536464
en_US
537465
"""
466+
467+
@require-wp-4.0
468+
Scenario: List languages by multiple statuses
469+
Given a WP install
470+
And an empty cache
471+
And I run `wp language core install nl_NL`
472+
473+
When I run `wp language core list --fields=language,status --status=active,installed`
474+
Then STDOUT should be a table containing rows:
475+
| language | status |
476+
| en_US | active |
477+
| nl_NL | installed |
478+
And STDERR should be empty

0 commit comments

Comments
 (0)