From 3ae401076a693f7e14d63742faa8059a0bc9396a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 3 Nov 2025 13:47:12 +0000 Subject: [PATCH 1/4] Initial plan From 011035c64e26a9c6ccdd9dfc7770eb4df8187d63 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 3 Nov 2025 14:07:43 +0000 Subject: [PATCH 2/4] Add automatic PO-Revision-Date update in update-po command Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/updatepo.feature | 58 +++++++++++++++++++++++++++++++++++++++ src/UpdatePoCommand.php | 3 ++ 2 files changed, 61 insertions(+) diff --git a/features/updatepo.feature b/features/updatepo.feature index 6aba5e30..8e2cf8f7 100644 --- a/features/updatepo.feature +++ b/features/updatepo.feature @@ -465,3 +465,61 @@ Feature: Update existing PO files from a POT file """ "X-Domain: foo-plugin\n" """ + + Scenario: Updates PO-Revision-Date when updating a PO file + Given an empty foo-plugin directory + And a foo-plugin/foo-plugin.pot file: + """ + # Copyright (C) 2018 Foo Plugin + # This file is distributed under the same license as the Foo Plugin package. + msgid "" + msgstr "" + "Project-Id-Version: Foo Plugin\n" + "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n" + "Last-Translator: FULL NAME \n" + "Language-Team: LANGUAGE \n" + "MIME-Version: 1.0\n" + "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + "POT-Creation-Date: 2023-05-02T22:06:24+00:00\n" + "PO-Revision-Date: 2023-05-02T22:06:24+00:00\n" + "X-Domain: foo-plugin\n" + + #: foo-plugin.php:1 + msgid "Some string" + msgstr "" + """ + And a foo-plugin/foo-plugin-de_DE.po file: + """ + # Copyright (C) 2018 Foo Plugin + # This file is distributed under the same license as the Foo Plugin package. + msgid "" + msgstr "" + "Project-Id-Version: Foo Plugin\n" + "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n" + "Last-Translator: FULL NAME \n" + "Language-Team: LANGUAGE \n" + "Language: de_DE\n" + "MIME-Version: 1.0\n" + "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + "POT-Creation-Date: 2018-05-02T22:06:24+00:00\n" + "PO-Revision-Date: 2018-05-02T22:06:24+00:00\n" + "X-Domain: foo-plugin\n" + "Plural-Forms: nplurals=2; plural=(n != 1);\n" + + #: foo-plugin.php:1 + msgid "Some string" + msgstr "Some translated string" + """ + + When I run `wp i18n update-po foo-plugin/foo-plugin.pot` + Then STDOUT should be: + """ + Success: Updated 1 file. + """ + And STDERR should be empty + And the foo-plugin/foo-plugin-de_DE.po file should not contain: + """ + "PO-Revision-Date: 2018-05-02T22:06:24+00:00\n" + """ diff --git a/src/UpdatePoCommand.php b/src/UpdatePoCommand.php index 5af6b996..97160d6c 100644 --- a/src/UpdatePoCommand.php +++ b/src/UpdatePoCommand.php @@ -87,6 +87,9 @@ public function __invoke( $args, $assoc_args ) { Merge::ADD | Merge::REMOVE | Merge::COMMENTS_THEIRS | Merge::EXTRACTED_COMMENTS_THEIRS | Merge::REFERENCES_THEIRS | Merge::DOMAIN_OVERRIDE ); + // Update PO-Revision-Date to current date and time. + $po_translations->setHeader( 'PO-Revision-Date', gmdate( 'Y-m-d\TH:i:sP' ) ); + if ( ! $po_translations->toPoFile( $file->getPathname() ) ) { WP_CLI::warning( sprintf( 'Could not update file %s', $file->getPathname() ) ); continue; From b1a97f946df74888e3e006a7bc8aa16744c200b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 3 Nov 2025 14:08:43 +0000 Subject: [PATCH 3/4] Improve comment to clarify use of gmdate() for UTC consistency Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/UpdatePoCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/UpdatePoCommand.php b/src/UpdatePoCommand.php index 97160d6c..4fec1706 100644 --- a/src/UpdatePoCommand.php +++ b/src/UpdatePoCommand.php @@ -87,7 +87,8 @@ public function __invoke( $args, $assoc_args ) { Merge::ADD | Merge::REMOVE | Merge::COMMENTS_THEIRS | Merge::EXTRACTED_COMMENTS_THEIRS | Merge::REFERENCES_THEIRS | Merge::DOMAIN_OVERRIDE ); - // Update PO-Revision-Date to current date and time. + // Update PO-Revision-Date to current date and time in UTC. + // Uses gmdate() for consistency across different server timezones. $po_translations->setHeader( 'PO-Revision-Date', gmdate( 'Y-m-d\TH:i:sP' ) ); if ( ! $po_translations->toPoFile( $file->getPathname() ) ) { From 2f6ae55ec6b2d0711781542dbfe0b3e6e4789a0a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 3 Nov 2025 18:32:23 +0100 Subject: [PATCH 4/4] Slightly improve test --- features/updatepo.feature | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/features/updatepo.feature b/features/updatepo.feature index 8e2cf8f7..789f4652 100644 --- a/features/updatepo.feature +++ b/features/updatepo.feature @@ -519,6 +519,10 @@ Feature: Update existing PO files from a POT file Success: Updated 1 file. """ And STDERR should be empty + And the foo-plugin/foo-plugin-de_DE.po file should contain: + """ + "PO-Revision-Date: + """ And the foo-plugin/foo-plugin-de_DE.po file should not contain: """ "PO-Revision-Date: 2018-05-02T22:06:24+00:00\n"