php-gettext / Gettext

PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)
MIT License
687 stars 132 forks source link

PHP functions prefixed with a slash are being ignored #284

Closed dgwyer closed 1 year ago

dgwyer commented 1 year ago

I thought this issue was directly related to wp-cli and so I posted the original message there: https://github.com/wp-cli/i18n-command/issues/344

Basically when prefixing a PHP i18n with a slash it gets ignored.

e.g.

<?php
// wp i18n make-pot . --domain=bar
\esc_html__('foo', 'bar'); // ignored
esc_html__('baz', 'bar'); // processed
oscarotero commented 1 year ago

This is in Gettext 4, right?

I'm not working on maintaining this version (not enough time) but accept PR. If you want to work on that, I guess this can be fixed somewhere here: https://github.com/php-gettext/Gettext/blob/4.x/src/Utils/PhpFunctionsScanner.php#L117

remcotolsma commented 1 year ago

It might be good to know that this seems to work well on PHP 7.4, but it goes wrong in PHP 8:

oscarotero commented 1 year ago

Fixed and released in v4.8.8