i18n-command/features/updatepo.feature

866 lines
28 KiB
Gherkin

Feature: Update existing PO files from a POT file
Background:
Given an empty directory
Scenario: Bail for invalid source file
When I try `wp i18n update-po bar/baz.pot`
Then STDERR should contain:
"""
Error: Source file does not exist.
"""
And the return code should be 1
Scenario: Does nothing if there are no PO files
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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#: foo-plugin.js:15
msgid "Foo Plugin"
msgstr ""
"""
When I run `wp i18n update-po foo-plugin/foo-plugin.pot`
Then STDOUT should be:
"""
Success: Updated 0 files.
"""
And STDERR should be empty
Scenario: Updates all PO files in the source directory by default
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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#. translators: New Comment.
#: foo-plugin.php:1
msgid "Some string"
msgstr ""
#: foo-plugin.php:15
msgid "Another new string"
msgstr ""
#: foo-plugin.php:30
msgid "You have %d new message"
msgid_plural "You have %d new messages"
"""
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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#. translators: Old Comment.
#: foo-plugin.php:10
msgid "Some string"
msgstr "Some translated string"
#: foo-plugin.php:60
msgid "You have %d new message"
msgid_plural "You have %d new messages"
msgstr[0] "Sie haben %d neue Nachricht"
msgstr[1] "Sie haben %d neue Nachrichten"
"""
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 contain:
"""
#. translators: New Comment.
#: foo-plugin.php:1
msgid "Some string"
msgstr "Some translated string"
"""
And the foo-plugin/foo-plugin-de_DE.po file should contain:
"""
#: foo-plugin.php:15
msgid "Another new string"
msgstr ""
"""
And the foo-plugin/foo-plugin-de_DE.po file should contain:
"""
#: foo-plugin.php:30
msgid "You have %d new message"
msgid_plural "You have %d new messages"
msgstr[0] "Sie haben %d neue Nachricht"
msgstr[1] "Sie haben %d neue Nachrichten"
"""
And the foo-plugin/foo-plugin-de_DE.po file should not contain:
"""
#. translators: Old Comment.
"""
And the foo-plugin/foo-plugin-de_DE.po file should not contain:
"""
#: foo-plugin.php:10
"""
Scenario: Updates the specified target 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#. translators: New Comment.
#: foo-plugin.php:1
msgid "Some string"
msgstr ""
#: foo-plugin.php:15
msgid "Another new 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#. translators: Old Comment.
#: foo-plugin.php:10
msgid "Some string"
msgstr "Some translated string"
"""
And a foo-plugin/foo-plugin-es_ES.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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#. translators: Old Comment.
#: foo-plugin.php:10
msgid "Some string"
msgstr "Some translated string"
"""
When I run `wp i18n update-po foo-plugin/foo-plugin.pot foo-plugin/foo-plugin-de_DE.po`
Then STDOUT should be:
"""
Success: Updated 1 file.
"""
And STDERR should be empty
And the foo-plugin/foo-plugin-de_DE.po file should contain:
"""
#. translators: New Comment.
#: foo-plugin.php:1
msgid "Some string"
msgstr "Some translated string"
#: foo-plugin.php:15
msgid "Another new string"
msgstr ""
"""
And the foo-plugin/foo-plugin-es_ES.po file should contain:
"""
#. translators: Old Comment.
"""
And the foo-plugin/foo-plugin-es_ES.po file should contain:
"""
#: foo-plugin.php:10
"""
Scenario: Updates all PO files in the specified target directory
Given an empty source directory
And an empty target directory
And a source/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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#. translators: New Comment.
#: foo-plugin.php:1
msgid "Some string"
msgstr ""
#: foo-plugin.php:15
msgid "Another new string"
msgstr ""
"""
And a target/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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#. translators: Old Comment.
#: foo-plugin.php:10
msgid "Some string"
msgstr "Some translated string"
"""
And a target/foo-plugin-es_ES.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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#. translators: Old Comment.
#: foo-plugin.php:10
msgid "Some string"
msgstr "Some translated string"
"""
When I run `wp i18n update-po source/foo-plugin.pot target`
Then STDOUT should be:
"""
Success: Updated 2 files.
"""
And STDERR should be empty
And the target/foo-plugin-de_DE.po file should contain:
"""
#. translators: New Comment.
#: foo-plugin.php:1
msgid "Some string"
msgstr "Some translated string"
#: foo-plugin.php:15
msgid "Another new string"
msgstr ""
"""
And the target/foo-plugin-es_ES.po file should contain:
"""
#. translators: New Comment.
#: foo-plugin.php:1
msgid "Some string"
msgstr "Some translated string"
#: foo-plugin.php:15
msgid "Another new string"
msgstr ""
"""
Scenario: Return error in case of incorrect destination set
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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#. translators: New Comment.
#: foo-plugin.php:1
msgid "Some string"
msgstr ""
#: foo-plugin.php:15
msgid "Another new string"
msgstr ""
#: foo-plugin.php:30
msgid "You have %d new message"
msgid_plural "You have %d new messages"
"""
When I try `wp i18n update-po foo-plugin/foo-plugin.pot foo-plugin/test`
Then STDERR should contain:
"""
Error: Destination file/folder does not exist.
"""
And the return code should be 1
Scenario: Empty target 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#. translators: New Comment.
#: foo-plugin.php:1
msgid "Some string"
msgstr ""
#: foo-plugin.php:15
msgid "Another new 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#. translators: Old Comment.
#: foo-plugin.php:10
msgid "Some string"
msgstr "Some translated string"
"""
And a foo-plugin/foo-plugin-es_ES.po file:
"""
"""
When I run `wp i18n update-po foo-plugin/foo-plugin.pot foo-plugin/foo-plugin-de_DE.po`
Then STDOUT should be:
"""
Success: Updated 1 file.
"""
And the foo-plugin/foo-plugin-de_DE.po file should contain:
"""
#. translators: New Comment.
#: foo-plugin.php:1
msgid "Some string"
msgstr "Some translated string"
#: foo-plugin.php:15
msgid "Another new string"
msgstr ""
"""
And the foo-plugin/foo-plugin-de_DE.po file should contain:
"""
"X-Domain: foo-plugin\n"
"""
Scenario: Preserves obsolete translations and file-level comments with --no-purge
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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#: 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#~ msgid "Obsolete string"
#~ msgstr "Veralteter String"
"""
When I run `wp i18n update-po foo-plugin/foo-plugin.pot foo-plugin/foo-plugin-de_DE.po --no-purge`
Then STDOUT should be:
"""
Success: Updated 1 file.
"""
And STDERR should be empty
And the foo-plugin/foo-plugin-de_DE.po file should contain:
"""
# Copyright (C) 2018 Foo Plugin
# This file is distributed under the same license as the Foo Plugin package.
"""
And the foo-plugin/foo-plugin-de_DE.po file should contain:
"""
#~ msgid "Obsolete string"
#~ msgstr "Veralteter String"
"""
And the foo-plugin/foo-plugin-de_DE.po file should contain:
"""
#: foo-plugin.php:1
msgid "Some string"
msgstr "Some translated string"
"""
Scenario: Removes obsolete translations and comments by default
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin.pot file:
"""
msgid ""
msgstr ""
"Project-Id-Version: Foo Plugin\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/foo-plugin\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#: 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#~ msgid "Obsolete string"
#~ msgstr "Veralteter String"
"""
When I run `wp i18n update-po foo-plugin/foo-plugin.pot foo-plugin/foo-plugin-de_DE.po`
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:
"""
# Copyright (C) 2018 Foo Plugin
"""
And the foo-plugin/foo-plugin-de_DE.po file should not contain:
"""
#~ msgid "Obsolete string"
"""
And the foo-plugin/foo-plugin-de_DE.po file should contain:
"""
#: foo-plugin.php:1
msgid "Some string"
msgstr "Some translated string"
"""
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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 ""
#: foo-plugin.php:2
msgid "Some other 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 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"
"""
Scenario: Keeps POT file order of translations
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"
"Content-Type: text/plain; charset=UTF-8\n"
"X-Domain: foo-plugin\n"
#: foo-plugin.php:1
msgid "First string"
msgstr ""
#: foo-plugin.php:10
msgid "Second string"
msgstr ""
#: foo-plugin.php:20
msgid "Third 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"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: de_DE\n"
"X-Domain: foo-plugin\n"
#: foo-plugin.php:20
msgid "Third string"
msgstr "Dritte Zeichenfolge"
#: foo-plugin.php:1
msgid "First string"
msgstr "Erste Zeichenfolge"
"""
When I run `wp i18n update-po foo-plugin/foo-plugin.pot foo-plugin/foo-plugin-de_DE.po`
Then STDOUT should be:
"""
Success: Updated 1 file.
"""
And STDERR should be empty
And the contents of the foo-plugin/foo-plugin-de_DE.po file should match /First string.*Second string.*Third string/s
Scenario: Reports unchanged files when POT hasn't changed
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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#: 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 0 files. 1 file unchanged.
"""
And STDERR should be empty
Scenario: Reports both updated and unchanged files
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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#: foo-plugin.php:1
msgid "Some string"
msgstr ""
#: foo-plugin.php:15
msgid "Another new 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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:10
msgid "Some string"
msgstr "Some translated string"
"""
And a foo-plugin/foo-plugin-es_ES.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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: es_ES\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"
#: foo-plugin.php:15
msgid "Another new string"
msgstr "Otra nueva cadena"
"""
When I run `wp i18n update-po foo-plugin/foo-plugin.pot`
Then STDOUT should be:
"""
Success: Updated 1 file. 1 file unchanged.
"""
And STDERR should be empty