php-gettext / PHP-Scanner

PHP code scanner for gettext
MIT License
14 stars 5 forks source link

The php-format flag is missing #12

Closed Goral64 closed 3 years ago

Goral64 commented 3 years ago

The scanner does not add the php-format flag for gettext() arguments that are a format string for sprintf() functions such as %s or %d. For example: sprintf(gettext("This is %s"), $value); does not return flag #, php-format

oscarotero commented 3 years ago

I didn't know this flag. Is this a standard?

Goral64 commented 3 years ago

https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html

php-format no-php-format Likewise for PHP, see php-format.

https://www.gnu.org/software/gettext/manual/html_node/php_002dformat.html#php_002dformat 15.3.24 PHP Format Strings PHP format strings are described in the documentation of the PHP function sprintf, in phpdoc/manual/function.sprintf.html or http://www.php.net/manual/en/function.sprintf.php.

oscarotero commented 3 years ago

I've implemented a regexp to detect if the original text includes a sprintf expression: https://github.com/php-gettext/PHP-Scanner/blob/master/src/PhpScanner.php#L58

Could you check if it works fine to you, before release a new version?

Goral64 commented 3 years ago

It seems to be working very well. Thank you and I look forward to the PR.

oscarotero commented 3 years ago

Ok, new version released including this.