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

PHP comments wrongly associated with preceding function #194

Open
swissspidy opened this issue Oct 27, 2018 · 1 comment
Open

PHP comments wrongly associated with preceding function #194

swissspidy opened this issue Oct 27, 2018 · 1 comment

Comments

@swissspidy
Copy link
Contributor

As reported in wp-cli/i18n-command#96, we're currently facing an issue with the PHP extractor where comments are associated with the wrong function call.

Here's an example code:

$month_abbrev[ __( 'January' ) ] = /* allowed1: three-letter abbreviation of the month */ __( 'Jan' );
$month_abbrev[ __( 'February' ) ] = /* allowed1: three-letter abbreviation of the month */ __( 'Feb' );

The expected result is like this:

#: ./tests/assets/phpcode3/input.php:13
msgid "January"
msgstr ""

#. allowed1: three-letter abbreviation of the month
#: ./tests/assets/phpcode3/input.php:13
msgid "Jan"
msgstr ""

#: ./tests/assets/phpcode3/input.php:14
msgid "February"
msgstr ""

#. allowed1: three-letter abbreviation of the month
#: ./tests/assets/phpcode3/input.php:14
msgid "Feb"
msgstr ""

What actually happens is that the second allowed1: three-letter abbreviation of the month comment is not associated with the Feb string, but instead with the February string. The January string is fine though.

I'm not yet sure what exactly in \Gettext\Utils\PhpFunctionsScanner::getFunctions() causes this but I wanted to report this already nonetheless.

@kkmuffme
Copy link

Major annoyance - would be amazing if somebody could take a look at this

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

No branches or pull requests

2 participants