-
Notifications
You must be signed in to change notification settings - Fork 58
Add support for pretty-printing PHP files in wp i18n make-php command #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sovetski
wants to merge
5
commits into
wp-cli:main
Choose a base branch
from
sovetski:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d966001
Add support for pretty-printing PHP files in wp i18n make-php command
sovetski 1edfaa0
Update makephp.feature to fix file extension, add missing newline at …
sovetski e2872d2
Actually use `pretty-print` in test
swissspidy 9c89886
Fix pretty-printing of PHP files in wp i18n make-php command
sovetski 3899f6b
Fix indentation in PhpArrayGenerator.php
sovetski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,3 +259,63 @@ Feature: Generate PHP files from PO files | |
""" | ||
new message | ||
""" | ||
|
||
Scenario: Should create pretty-printed PHP files | ||
Given an empty foo-plugin directory | ||
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 <[email protected]>\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.js:15 | ||
msgid "Foo Plugin" | ||
msgstr "Foo Plugin" | ||
|
||
#: foo-plugin.js:16 | ||
msgid "Hello" | ||
msgstr "Hallo" | ||
|
||
#: foo-plugin.js:17 | ||
msgid "You have %d new message" | ||
msgid_plural "You have %d new messages" | ||
msgstr[0] "Du hast %d neue Nachricht" | ||
msgstr[1] "Du hast %d neue Nachrichten" | ||
""" | ||
|
||
When I run `wp i18n make-php foo-plugin --pretty-print` | ||
Then STDOUT should contain: | ||
""" | ||
Success: Created 1 file. | ||
""" | ||
And the return code should be 0 | ||
And the foo-plugin/foo-plugin-de_DE.l10n.php file should contain: | ||
""" | ||
<?php | ||
swissspidy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return [ | ||
'domain' => 'foo-plugin', | ||
'plural-forms' => 'nplurals=2; plural=(n != 1);', | ||
'language' => 'de_DE', | ||
'project-id-version' => 'Foo Plugin', | ||
'pot-creation-date' => '2018-05-02T22:06:24+00:00', | ||
'po-revision-date' => '2018-05-02T22:06:24+00:00', | ||
'messages' => [ | ||
'Foo Plugin' => 'Foo Plugin', | ||
'Hello' => 'Hallo', | ||
'You have %d new message' => 'Du hast %d neue Nachricht' . "\0" . 'Du hast %d neue Nachrichten', | ||
], | ||
]; | ||
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.