Skip to content

Commit 7eb019d

Browse files
authored
Merge pull request #463 from wp-cli/copilot/fix-1570774-111592377-2de30966-a56a-48ed-b8c6-d3a72d2c71bc
2 parents 23f34c3 + 280b942 commit 7eb019d

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

features/updatepo.feature

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,3 +465,65 @@ Feature: Update existing PO files from a POT file
465465
"""
466466
"X-Domain: foo-plugin\n"
467467
"""
468+
469+
Scenario: Updates PO-Revision-Date when updating a PO file
470+
Given an empty foo-plugin directory
471+
And a foo-plugin/foo-plugin.pot file:
472+
"""
473+
# Copyright (C) 2018 Foo Plugin
474+
# This file is distributed under the same license as the Foo Plugin package.
475+
msgid ""
476+
msgstr ""
477+
"Project-Id-Version: Foo Plugin\n"
478+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n"
479+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
480+
"Language-Team: LANGUAGE <[email protected]>\n"
481+
"MIME-Version: 1.0\n"
482+
"Content-Type: text/plain; charset=UTF-8\n"
483+
"Content-Transfer-Encoding: 8bit\n"
484+
"POT-Creation-Date: 2023-05-02T22:06:24+00:00\n"
485+
"PO-Revision-Date: 2023-05-02T22:06:24+00:00\n"
486+
"X-Domain: foo-plugin\n"
487+
488+
#: foo-plugin.php:1
489+
msgid "Some string"
490+
msgstr ""
491+
"""
492+
And a foo-plugin/foo-plugin-de_DE.po file:
493+
"""
494+
# Copyright (C) 2018 Foo Plugin
495+
# This file is distributed under the same license as the Foo Plugin package.
496+
msgid ""
497+
msgstr ""
498+
"Project-Id-Version: Foo Plugin\n"
499+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n"
500+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
501+
"Language-Team: LANGUAGE <[email protected]>\n"
502+
"Language: de_DE\n"
503+
"MIME-Version: 1.0\n"
504+
"Content-Type: text/plain; charset=UTF-8\n"
505+
"Content-Transfer-Encoding: 8bit\n"
506+
"POT-Creation-Date: 2018-05-02T22:06:24+00:00\n"
507+
"PO-Revision-Date: 2018-05-02T22:06:24+00:00\n"
508+
"X-Domain: foo-plugin\n"
509+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
510+
511+
#: foo-plugin.php:1
512+
msgid "Some string"
513+
msgstr "Some translated string"
514+
"""
515+
516+
When I run `wp i18n update-po foo-plugin/foo-plugin.pot`
517+
Then STDOUT should be:
518+
"""
519+
Success: Updated 1 file.
520+
"""
521+
And STDERR should be empty
522+
And the foo-plugin/foo-plugin-de_DE.po file should contain:
523+
"""
524+
"PO-Revision-Date:
525+
"""
526+
And the foo-plugin/foo-plugin-de_DE.po file should not contain:
527+
"""
528+
"PO-Revision-Date: 2018-05-02T22:06:24+00:00\n"
529+
"""

src/UpdatePoCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ public function __invoke( $args, $assoc_args ) {
8787
Merge::ADD | Merge::REMOVE | Merge::COMMENTS_THEIRS | Merge::EXTRACTED_COMMENTS_THEIRS | Merge::REFERENCES_THEIRS | Merge::DOMAIN_OVERRIDE
8888
);
8989

90+
// Update PO-Revision-Date to current date and time in UTC.
91+
// Uses gmdate() for consistency across different server timezones.
92+
$po_translations->setHeader( 'PO-Revision-Date', gmdate( 'Y-m-d\TH:i:sP' ) );
93+
9094
if ( ! $po_translations->toPoFile( $file->getPathname() ) ) {
9195
WP_CLI::warning( sprintf( 'Could not update file %s', $file->getPathname() ) );
9296
continue;

0 commit comments

Comments
 (0)