From f1b6e3206fe01d187810f8263ca8afbcd829e398 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 25 Jul 2018 21:10:16 +0200 Subject: [PATCH] Add X-Generator header to POT file See #53. --- features/makepot.feature | 10 ++++++++-- src/MakePotCommand.php | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/features/makepot.feature b/features/makepot.feature index 70fba32e..83949f16 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -94,7 +94,7 @@ Feature: Generate a POT file of a WordPress plugin When I run `wp scaffold plugin hello-world` When I run `wp i18n make-pot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot` - And the wp-content/plugins/hello-world/languages/hello-world.pot file should contain: + Then the wp-content/plugins/hello-world/languages/hello-world.pot file should contain: """ "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/hello-world\n" """ @@ -103,12 +103,18 @@ Feature: Generate a POT file of a WordPress plugin When I run `wp scaffold plugin hello-world` When I run `wp i18n make-pot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot` - And the wp-content/plugins/hello-world/languages/hello-world.pot file should contain: + Then the wp-content/plugins/hello-world/languages/hello-world.pot file should contain: """ "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" """ + Scenario: Sets the generator header + When I run `wp scaffold plugin hello-world` + + When I run `wp i18n make-pot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot` + Then the contents of the wp-content/plugins/hello-world/languages/hello-world.pot file should match /X-Generator:\s/ + Scenario: Ignores any other text domain Given an empty foo-plugin directory And a foo-plugin/foo-plugin.php file: diff --git a/src/MakePotCommand.php b/src/MakePotCommand.php index 840b2553..4e2062a8 100644 --- a/src/MakePotCommand.php +++ b/src/MakePotCommand.php @@ -413,6 +413,7 @@ protected function set_default_headers() { $this->translations->setHeader( 'Report-Msgid-Bugs-To', $meta['msgid-bugs-address'] ); $this->translations->setHeader( 'Last-Translator', 'FULL NAME ' ); $this->translations->setHeader( 'Language-Team', 'LANGUAGE ' ); + $this->translations->setHeader( 'X-Generator', 'WP-CLI ' . WP_CLI_VERSION ); } /**