Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3bd980a
Initial plan
Copilot Nov 2, 2025
a44033d
Add --format flag support to language update commands
Copilot Nov 2, 2025
4594dcb
Add tests for --format flag in update commands
Copilot Nov 2, 2025
3f88849
Fix format output for empty update results
Copilot Nov 2, 2025
2ec032e
Refactor update method to avoid code duplication and fix slug key logic
Copilot Nov 2, 2025
75f704d
Optimize data collection to skip summary format
Copilot Nov 2, 2025
7978aad
Use WP_CLI::log instead of WP_CLI::line for proper quiet logger support
Copilot Nov 2, 2025
c62f573
Improve maintainability by using slug_key variable consistently
Copilot Nov 2, 2025
e0157bf
Fix format output to suppress success message and use standard test f…
Copilot Nov 3, 2025
73abc92
Show success message only for summary format and add tests with actua…
Copilot Nov 3, 2025
fd5a464
Fix test expectations and remove invalid --force flag from language i…
Copilot Nov 3, 2025
374d75e
Fix format handling to show success messages for table format
Copilot Nov 3, 2025
1e612fb
Uninstall language before reinstalling to ensure updates are triggered
Copilot Nov 3, 2025
ef8e06f
Fix dry-run output to show message for table/summary formats and fix …
Copilot Nov 3, 2025
683e5b9
Lint fixes
swissspidy Nov 3, 2025
b4870d3
Merge branch 'main' into copilot/add-format-flag-to-update-commands
swissspidy Dec 19, 2025
5fd48aa
Merge branch 'main' into copilot/add-format-flag-to-update-commands
swissspidy Jan 20, 2026
bf304ba
Add dry-run with format flag tests and fix documentation
Copilot Jan 21, 2026
e12d2e8
Merge branch 'main' into copilot/add-format-flag-to-update-commands
swissspidy Jan 21, 2026
715eb3e
Fix synopsis
swissspidy Jan 21, 2026
554eaa3
Fix dry-run with summary format to produce no output
Copilot Feb 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions features/language-core.feature
Original file line number Diff line number Diff line change
Expand Up @@ -476,3 +476,74 @@ Feature: Manage core translation files for a WordPress install
| en_US | active |
| nl_NL | installed |
And STDERR should be empty

@require-wp-4.0
Scenario: Core translation update with format flag
Given a WP install
And an empty cache

When I run `wp language core update --format=json`
Then STDOUT should be:
"""
[]
"""
And STDERR should be empty

When I run `wp language core update --format=csv`
Then STDOUT should be empty
And STDERR should be empty

When I run `wp language core update --format=summary`
Then STDOUT should contain:
"""
Success: Translations are up to date.
"""
And STDERR should be empty

@require-wp-6.0 @require-php-7.2
Scenario Outline: Core translation update with dry-run and format flag
Given an empty directory
And WP files
And a database
And I run `wp core download --version=<original> --force`
And wp-config.php
And I run `wp core install --url='localhost:8001' --title='Test' --admin_user=wpcli --admin_email=admin@example.com --admin_password=1`

When I run `wp language core install en_CA ja`
Then STDERR should be empty

Given I try `wp core download --version=<update> --force`
Then the return code should be 0
And I run `wp core update-db`

When I run `wp language core list --fields=language,status,update`
Then STDOUT should be a table containing rows:
| language | status | update |
| en_CA | installed | available |
| ja | installed | available |

When I run `wp language core update --dry-run --format=json`
Then STDOUT should be JSON containing:
"""
[{"Type":"Core","Name":"WordPress","Version":"<update>"}]
"""
And STDERR should be empty

When I run `wp language core update --dry-run --format=csv`
Then STDOUT should contain:
"""
Type,Name,Version,Language
"""
And STDOUT should contain:
"""
Core,WordPress,<update>
"""
And STDERR should be empty

When I run `wp language core update --dry-run --format=summary`
Then STDOUT should be empty
And STDERR should be empty

Examples:
| original | update |
| 6.5 | 6.6 |
113 changes: 113 additions & 0 deletions features/language-plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,119 @@ Feature: Manage plugin translation files for a WordPress install
And STDERR should be empty

@require-wp-4.0
Scenario: Plugin translation update with format flag
Given a WP install

When I run `wp plugin install hello-dolly --force`
Then STDERR should be empty

When I run `wp language plugin update hello-dolly --format=json`
Then STDOUT should be:
"""
[]
"""
And STDERR should be empty

When I run `wp language plugin update --all --format=csv`
Then STDOUT should be empty
And STDERR should be empty

When I run `wp language plugin update --all --format=summary`
Then STDOUT should contain:
"""
Success: Translations are up to date.
"""
And STDERR should be empty

@require-wp-4.0
Scenario: Plugin translation update with format flag and actual updates
Given a WP install
And an empty cache

When I run `wp plugin install akismet --version=3.2 --force`
Then STDERR should be empty

When I run `wp language plugin install akismet de_DE`
Then STDERR should be empty

When I run `wp plugin install akismet --version=4.0 --force`
And I run `wp language plugin list akismet --fields=plugin,language,update,status`
Then STDOUT should be a table containing rows:
| plugin | language | update | status |
| akismet | de_DE | available | installed |

When I run `wp language plugin update akismet --format=json`
Then STDOUT should be JSON containing:
"""
[{"slug":"akismet","language":"de_DE","status":"updated"}]
"""
And STDERR should be empty

When I run `wp language plugin uninstall akismet de_DE`
And I run `wp plugin install akismet --version=3.2 --force`
And I run `wp language plugin install akismet de_DE`
And I run `wp plugin install akismet --version=4.0 --force`
And I run `wp language plugin update akismet --format=csv`
Then STDOUT should contain:
"""
slug,language,status
"""
And STDOUT should contain:
"""
akismet,de_DE,updated
"""
And STDERR should be empty

When I run `wp language plugin uninstall akismet de_DE`
And I run `wp plugin install akismet --version=3.2 --force`
And I run `wp language plugin install akismet de_DE`
And I run `wp plugin install akismet --version=4.0 --force`
And I run `wp language plugin update akismet --format=summary`
Then STDOUT should contain:
"""
Success: Updated 1/1 translation.
"""
And STDERR should be empty

@require-wp-4.0
Scenario: Plugin translation update with dry-run and format flag
Given a WP install
And an empty cache

When I run `wp plugin install akismet --version=3.2 --force`
Then STDERR should be empty

When I run `wp language plugin install akismet de_DE`
Then STDERR should be empty

When I run `wp plugin install akismet --version=4.0 --force`
And I run `wp language plugin list akismet --fields=plugin,language,update,status`
Then STDOUT should be a table containing rows:
| plugin | language | update | status |
| akismet | de_DE | available | installed |

When I run `wp language plugin update akismet --dry-run --format=json`
Then STDOUT should be JSON containing:
"""
[{"Type":"Plugin","Name":"Akismet Anti-spam: Spam Protection"}]
"""
And STDERR should be empty

When I run `wp language plugin update akismet --dry-run --format=csv`
Then STDOUT should contain:
"""
Type,Name,Version,Language
"""
And STDOUT should contain:
"""
Plugin,Akismet Anti-spam: Spam Protection
"""
And STDERR should be empty

When I run `wp language plugin update akismet --dry-run --format=summary`
Then STDOUT should be empty
And STDERR should be empty

Scenario: Handle plugins with text domain different from slug
Given a WP install
And an empty cache
Expand Down
113 changes: 113 additions & 0 deletions features/language-theme.feature
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,119 @@ Feature: Manage theme translation files for a WordPress install
And STDERR should be empty

@require-wp-4.0
Scenario: Theme translation update with format flag
Given a WP install

When I try `wp theme install twentyten`
Then STDOUT should not be empty

When I run `wp language theme update twentyten --format=json`
Then STDOUT should be:
"""
[]
"""
And STDERR should be empty

When I run `wp language theme update --all --format=csv`
Then STDOUT should be empty
And STDERR should be empty

When I run `wp language theme update --all --format=summary`
Then STDOUT should contain:
"""
Success: Translations are up to date.
"""
And STDERR should be empty

@require-wp-4.0
Scenario: Theme translation update with format flag and actual updates
Given a WP install
And an empty cache

When I run `wp theme install twentyfifteen --version=2.0 --force`
Then STDERR should be empty

When I run `wp language theme install twentyfifteen de_DE`
Then STDERR should be empty

When I run `wp theme install twentyfifteen --version=2.5 --force`
And I run `wp language theme list twentyfifteen --fields=theme,language,update,status`
Then STDOUT should be a table containing rows:
| theme | language | update | status |
| twentyfifteen | de_DE | available | installed |

When I run `wp language theme update twentyfifteen --format=json`
Then STDOUT should be JSON containing:
"""
[{"slug":"twentyfifteen","language":"de_DE","status":"updated"}]
"""
And STDERR should be empty

When I run `wp language theme uninstall twentyfifteen de_DE`
And I run `wp theme install twentyfifteen --version=2.0 --force`
And I run `wp language theme install twentyfifteen de_DE`
And I run `wp theme install twentyfifteen --version=2.5 --force`
And I run `wp language theme update twentyfifteen --format=csv`
Then STDOUT should contain:
"""
slug,language,status
"""
And STDOUT should contain:
"""
twentyfifteen,de_DE,updated
"""
And STDERR should be empty

When I run `wp language theme uninstall twentyfifteen de_DE`
And I run `wp theme install twentyfifteen --version=2.0 --force`
And I run `wp language theme install twentyfifteen de_DE`
And I run `wp theme install twentyfifteen --version=2.5 --force`
And I run `wp language theme update twentyfifteen --format=summary`
Then STDOUT should contain:
"""
Success: Updated 1/1 translation.
"""
And STDERR should be empty

@require-wp-4.0
Scenario: Theme translation update with dry-run and format flag
Given a WP install
And an empty cache

When I run `wp theme install twentyfifteen --version=2.0 --force`
Then STDERR should be empty

When I run `wp language theme install twentyfifteen de_DE`
Then STDERR should be empty

When I run `wp theme install twentyfifteen --version=2.5 --force`
And I run `wp language theme list twentyfifteen --fields=theme,language,update,status`
Then STDOUT should be a table containing rows:
| theme | language | update | status |
| twentyfifteen | de_DE | available | installed |

When I run `wp language theme update twentyfifteen --dry-run --format=json`
Then STDOUT should be JSON containing:
"""
[{"Type":"Theme","Name":"Twenty Fifteen"}]
"""
And STDERR should be empty

When I run `wp language theme update twentyfifteen --dry-run --format=csv`
Then STDOUT should contain:
"""
Type,Name,Version,Language
"""
And STDOUT should contain:
"""
Theme,Twenty Fifteen
"""
And STDERR should be empty

When I run `wp language theme update twentyfifteen --dry-run --format=summary`
Then STDOUT should be empty
And STDERR should be empty

Scenario: Handle themes with text domain different from slug
Given a WP install
And an empty cache
Expand Down
14 changes: 13 additions & 1 deletion src/Core_Language_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,18 @@ public function uninstall( $args ) {
* [--dry-run]
* : Preview which translations would be updated.
*
* [--format=<format>]
* : Render output in a particular format. When not specified, updates show
* progress messages and success/warning/error messages. When specified,
* the output format changes based on the selected format.
* ---
* options:
* - table
* - csv
* - json
* - summary
* ---
*
* ## EXAMPLES
*
* # Update installed core languages packs.
Expand All @@ -351,7 +363,7 @@ public function uninstall( $args ) {
* @subcommand update
*
* @param string[] $args Positional arguments.
* @param array{'dry-run'?: bool} $assoc_args Associative arguments.
* @param array{'dry-run'?: bool, format?: string} $assoc_args Associative arguments.
*/
public function update( $args, $assoc_args ) { // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Overruling the documentation, so not useless ;-).
parent::update( $args, $assoc_args );
Expand Down
14 changes: 13 additions & 1 deletion src/Plugin_Language_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,18 @@ public function uninstall( $args, $assoc_args ) {
* [--dry-run]
* : Preview which translations would be updated.
*
* [--format=<format>]
* : Render output in a particular format. When not specified, updates show
* progress messages and success/warning/error messages. When specified,
* the output format changes based on the selected format.
* ---
* options:
* - table
* - csv
* - json
* - summary
* ---
*
* ## EXAMPLES
*
* # Update all installed language packs for all plugins.
Expand All @@ -600,7 +612,7 @@ public function uninstall( $args, $assoc_args ) {
* @subcommand update
*
* @param string[] $args Positional arguments.
* @param array{'dry-run'?: bool, all?: bool} $assoc_args Associative arguments.
* @param array{'dry-run'?: bool, all?: bool, format?: string} $assoc_args Associative arguments.
*/
public function update( $args, $assoc_args ) {
$all = \WP_CLI\Utils\get_flag_value( $assoc_args, 'all', false );
Expand Down
14 changes: 13 additions & 1 deletion src/Theme_Language_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,18 @@ public function uninstall( $args, $assoc_args ) {
* [--dry-run]
* : Preview which translations would be updated.
*
* [--format=<format>]
* : Render output in a particular format. When not specified, updates show
* progress messages and success/warning/error messages. When specified,
* the output format changes based on the selected format.
* ---
* options:
* - table
* - csv
* - json
* - summary
* ---
*
* ## EXAMPLES
*
* # Update all installed language packs for all themes.
Expand All @@ -619,7 +631,7 @@ public function uninstall( $args, $assoc_args ) {
* @subcommand update
*
* @param string[] $args Positional arguments.
* @param array{'dry-run'?: bool, all?: bool} $assoc_args Associative arguments.
* @param array{'dry-run'?: bool, all?: bool, format?: string} $assoc_args Associative arguments.
*/
public function update( $args, $assoc_args ) {
$all = \WP_CLI\Utils\get_flag_value( $assoc_args, 'all', false );
Expand Down
Loading
Loading