Skip to content

Commit 3ec0f7b

Browse files
authored
Write the revision date as translation-revision-date in make-php (#503)
1 parent fff5e52 commit 3ec0f7b

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

‎features/makephp.feature‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,39 @@ Feature: Generate PHP files from PO files
153153
And STDERR should be empty
154154
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain:
155155
"""
156-
return ['domain'=>NULL,'plural-forms'=>'nplurals=2; plural=n != 1;','language'=>'de_DE','project-id-version'=>'Development (5.2.x)','pot-creation-date'=>'','po-revision-date'=>'2019-03-28 19:42+0300','x-generator'=>'Poedit 2.2.1','messages'=>['html_lang_attribute'=>'de-DE','text directionltr'=>'ltr','number_format_decimal_point'=>',','number_format_thousands_sep'=>'.','Update %s now'=>'Jetzt %s aktualisieren','[%1$s] Confirm Action: %2$s'=>'[%1$s] Aktion bestätigen: %2$s','[%s] Erasure Request Fulfilled'=>'[%s] Löschauftrag ausgeführt','[%s] Personal Data Export'=>'[%s] Export personenbezogener Daten']];
156+
return ['domain'=>NULL,'plural-forms'=>'nplurals=2; plural=n != 1;','language'=>'de_DE','project-id-version'=>'Development (5.2.x)','pot-creation-date'=>'','translation-revision-date'=>'2019-03-28 19:42+0300','x-generator'=>'Poedit 2.2.1','messages'=>['html_lang_attribute'=>'de-DE','text directionltr'=>'ltr','number_format_decimal_point'=>',','number_format_thousands_sep'=>'.','Update %s now'=>'Jetzt %s aktualisieren','[%1$s] Confirm Action: %2$s'=>'[%1$s] Aktion bestätigen: %2$s','[%s] Erasure Request Fulfilled'=>'[%s] Löschauftrag ausgeführt','[%s] Personal Data Export'=>'[%s] Export personenbezogener Daten']];
157+
"""
158+
159+
Scenario: Writes the revision date as translation-revision-date
160+
Given an empty foo-plugin directory
161+
And a foo-plugin/foo-plugin-de_DE.po file:
162+
"""
163+
# Copyright (C) 2018 Foo Plugin
164+
# This file is distributed under the same license as the Foo Plugin package.
165+
msgid ""
166+
msgstr ""
167+
"Project-Id-Version: Foo Plugin\n"
168+
"Language: de_DE\n"
169+
"MIME-Version: 1.0\n"
170+
"Content-Type: text/plain; charset=UTF-8\n"
171+
"Content-Transfer-Encoding: 8bit\n"
172+
"PO-Revision-Date: 2018-05-02T22:06:24+00:00\n"
173+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
174+
175+
#: foo-plugin.php:15
176+
msgid "Foo Plugin"
177+
msgstr "Bar Plugin"
178+
"""
179+
180+
When I run `wp i18n make-php foo-plugin`
181+
Then the return code should be 0
182+
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain:
183+
"""
184+
'translation-revision-date'=>'2018-05-02T22:06:24+00:00'
185+
"""
186+
And the foo-plugin/foo-plugin-de_DE.l10n.php file should not contain:
187+
"""
188+
'po-revision-date'
157189
"""
158190

159191
Scenario: Does include translations

‎src/PhpArrayGenerator.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ protected static function toArray( Translations $translations, $include_headers,
7171
$result['language'] = $language;
7272
}
7373

74+
// GlotPress exports the revision date as `translation-revision-date`, so use that name here too.
7475
$headers_allowlist = [
7576
'Project-Id-Version' => 'project-id-version',
7677
'POT-Creation-Date' => 'pot-creation-date',
77-
'PO-Revision-Date' => 'po-revision-date',
78+
'PO-Revision-Date' => 'translation-revision-date',
7879
'X-Generator' => 'x-generator',
7980
];
8081

0 commit comments

Comments
 (0)