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

The php-format flag is missing #12

Closed
Goral64 opened this issue Feb 12, 2021 · 5 comments
Closed

The php-format flag is missing #12

Goral64 opened this issue Feb 12, 2021 · 5 comments

Comments

@Goral64
Copy link

Goral64 commented Feb 12, 2021

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
Copy link
Member

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

@Goral64
Copy link
Author

Goral64 commented Feb 14, 2021

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 added a commit that referenced this issue Apr 1, 2021
@oscarotero
Copy link
Member

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
Copy link
Author

Goral64 commented Apr 1, 2021

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

@oscarotero
Copy link
Member

Ok, new version released including 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