Gettext
Gettext copied to clipboard
PHP comments wrongly associated with preceding function
As reported in https://github.com/wp-cli/i18n-command/issues/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.
Major annoyance - would be amazing if somebody could take a look at this