-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Parse PHP comments on the line before #164
Conversation
@swissspidy thanks for this contribution, it looks really good. /* this comment is extracted */
__('hello world');
/* this comment is not extracted because there's an 'echo' between the comment and the function */
echo __('hello world');
/* this comment is not extracted because there's a variable assignation */
$salute = __('hello world'); Now, all these comments are extracted, so I suggest to provide a way to configure whether the phpcode parser should extract the comments or not, in order to disable it on handle php returned by template compilers like twig or blade. |
I think it might be even simpler than that. In Gettext\Extractors\PhpCode::$options['extractComments'] = ''; This tells all extractors to extract comments by default, no matter what prefix they have. However, according to http://twig-extensions.readthedocs.io/en/latest/i18n.html, Twig templates will always have the Thus, I'd suggest not to use See c91726a for an example. Instead of putting that into |
Ok, that's great. |
Great! I just did that in 5024441. |
Added now, although that shouldn't really make any difference :-) |
Thank you very much! |
This aims to address #161 by simply adding all comments on the line before to the current function.
It seems to work fine, except that the Twig parser creates files like this:
For some reason, these line comments are now being picked up as translator comments and let the tests fail.