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

v4: Prevent adding the same translator comment to multiple functions #271

Merged
merged 2 commits into from Jul 13, 2021
Merged

v4: Prevent adding the same translator comment to multiple functions #271

merged 2 commits into from Jul 13, 2021

Conversation

swissspidy
Copy link
Contributor

It's been a while since my last my PR to this project.

You might recall that we're using this library in WP-CLI for string extraction in all of WordPress core and WordPress plugins.

Unfortunately due to different minimum PHP version requirements (still supporting PHP 5.6+) we can't use the latest version of the library yet.

That's why this bugfix is target at the 4.x branch and I hope you consider merging it.

The bug that we're facing with v4 is that translator comments get added to multiple functions if they are all on the same line, instead of just to 1 function.

The tests should demonstrate this, but basically with PHP code like this:

printf( /* translators: Hello */ __( 'World' ) );
__( 'No comment' );

printf( /* translators: Only used once */ __( 'Within printf: %s' ), __( 'placeholder' ) ); __( 'After printf' );

The two translator comments should only be added to __( 'World' ) and __( 'Within printf: %s' ), respectively.

This is the last version compatible with PHP 5.4.x.
Specifying the version like this instead of `*` massively speeds up dependency resolution in Composer.
@oscarotero
Copy link
Member

Great. Thank you! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants