Skip to content
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

Extend PotGenerator to improve plural forms output #128

Merged
merged 3 commits into from Mar 22, 2019

Conversation

@swissspidy
Copy link
Member

commented Dec 26, 2018

Fixes #121.

Note: Might need some more tests because this adds quite a lot of code from the upstream library.

@swissspidy swissspidy changed the title [WIP] Extend PotGenerator to improve plural forms output Extend PotGenerator to improve plural forms output Dec 26, 2018

@greatislander

This comment has been minimized.

Copy link
Contributor

commented Feb 12, 2019

@swissspidy I didn't see this— I'll test it with our project and see if it resolves the issue. Thanks!

@greatislander
Copy link
Contributor

left a comment

This resolves #121 in my testing.

src/PotGenerator.php Outdated Show resolved Hide resolved
}
}
if ( $translation->hasExtractedComments() ) {

This comment has been minimized.

Copy link
@schlessera

schlessera Feb 19, 2019

Member

This is not really needed, as you'll get an empty array back if not. Iterating over an empty array just does nothing anyway.

src/PotGenerator.php Outdated Show resolved Hide resolved
foreach ( $translations as $translation ) {
/** @var \Gettext\Translation $translation */
if ( $translation->hasComments() ) {

This comment has been minimized.

Copy link
@schlessera

schlessera Feb 19, 2019

Member

This is not really needed, as you'll get an empty array back if not. Iterating over an empty array just does nothing anyway.

if ( ! empty( static::$comments_before_headers ) ) {
$result = implode( "\n", static::$comments_before_headers ) . "\n";
$plural_form = $translations->getPluralForms();
$plural_size = is_array( $plural_form ) ? ( $plural_form[0] - 1 ) : 1;

This comment has been minimized.

Copy link
@schlessera

schlessera Feb 19, 2019

Member

This needs a comment to explain what happens and especially what $plural_form[0] - 1 means.

@schlessera

This comment has been minimized.

Copy link
Member

commented Feb 19, 2019

The code is not really pretty because there's so much static access going on in the original library, but I guess that can't be easily helped.

Apply suggestions from code review
Co-Authored-By: swissspidy <pascal.birchler@gmail.com>
@connerbw connerbw referenced this pull request Mar 13, 2019
@connerbw

This comment has been minimized.

Copy link
Contributor

commented Mar 22, 2019

If this isn't going to be merged soon, can someone sync 121-plural-forms with master? It's ~23 commits behind, there are fixes this branch could benefit from. (For example; #125) Then I can simply keep using composer require wp-cli/i18n-command:dev-121-plural-forms

@schlessera

This comment has been minimized.

Copy link
Member

commented Mar 22, 2019

@swissspidy I'm fine with merging this now. Do you feel good about this as well?

Regarding the tests, I would assume we'll notice when things go wrong because of the Behat tests anyway, even without precise unit tests?

@swissspidy

This comment has been minimized.

Copy link
Member Author

commented Mar 22, 2019

Sure. We can do some housekeeping here at some point in the future I guess.

@swissspidy swissspidy merged commit e4778a0 into master Mar 22, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@swissspidy swissspidy deleted the 121-plural-forms branch Mar 22, 2019

@schlessera

This comment has been minimized.

Copy link
Member

commented Mar 22, 2019

@connerbw This is merged into master now.

@schlessera schlessera added this to the 2.1.1 milestone Mar 22, 2019

connerbw added a commit to pressbooks/pb-cli that referenced this pull request Mar 22, 2019

Upgrade i18n-command to dev-master
The changes we needed have been released

See: wp-cli/i18n-command#128

connerbw added a commit to pressbooks/pb-cli that referenced this pull request Mar 22, 2019

Upgrade i18n-command to dev-master (#32)
The changes we needed have been released
See: wp-cli/i18n-command#128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.