-
Notifications
You must be signed in to change notification settings - Fork 52
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
Conversation
@swissspidy I didn't see this— I'll test it with our project and see if it resolves the issue. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resolves #121 in my testing.
} | ||
} | ||
|
||
if ( $translation->hasExtractedComments() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not really needed, as you'll get an empty array back if not. Iterating over an empty array just does nothing anyway.
|
||
foreach ( $translations as $translation ) { | ||
/** @var \Gettext\Translation $translation */ | ||
if ( $translation->hasComments() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a comment to explain what happens and especially what $plural_form[0] - 1
means.
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. |
Co-Authored-By: swissspidy <[email protected]>
If this isn't going to be merged soon, can someone sync |
@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? |
Sure. We can do some housekeeping here at some point in the future I guess. |
@connerbw This is merged into |
The changes we needed have been released See: wp-cli/i18n-command#128
The changes we needed have been released See: wp-cli/i18n-command#128
Extend PotGenerator to improve plural forms output
Fixes #121.
Note: Might need some more tests because this adds quite a lot of code from the upstream library.