I am a gettext ticket reporter that you refer to in your post. When I sent the ticket, I had something completely different, something more in these areas:
<?php $msg = _(<<<TXT He said: "Hello world!". TXT ); ?>
Gettext cannot extract text from such heredoc / nowdoc lines, but it can be really useful when translating large chunks of text.
In my case, I use gettext in the CLI PHP script to translate text fragments containing XML markup. This markup is part of the source text and must also be translated. To manually avoid every quote or apostrophe in the markup, messages are pretty hard to read in POedit or any other editor.
In your case, it seems that you want the interpolated code in the lines (heredoc / nowdoc) to be extracted. You can easily solve this problem by preparing the text before the actual interpolation:
<?php $t = _('test'); echo <<<EOD <h1>$t</h1> EOD ?>
I do not think this should be considered a mistake, because the exact equivalent of the code you posted using the heredoc syntax would be as follows:
<?php echo "<h1>{$t->_('test')}</h1>"; ?>
from which gettext cannot extract the message "test".
source share