I'm using PHP's gettext functions for doing localization. I'm using Poedit to do the actual translation, and with its "Update from sources" feature it is really easy to extract all the strings that need to be translated - except from inside heredoc syntax.
Poedit is using the xgettext program to generate the .po files from the PHP source files. And it works beautifully when the PHP code looks like this:
echo "<h1>". _("test") ."</h1>";
But the following doesn't get extracted (notice that a pseudo t-object needs to be used):
echo <<<EOD
<h1>{$->_('test')}
EOD;
In PHP code you could workaround the problem in the following way:
<?php
$t = _('test');
echo <<<EOD
<h1>$t</h1>
EOD
?>
But I really would prefer that the xgettext program could extract the string from inside the heredoc block.
A workaround for that has been suggested in the PHP documentation comments. The workaround is to treat tell the xgettext program to treat the PHP source files as Python code. But using this approach in Poedit gives me a lot of syntax errors from the xgettext parser.
Does anyone know a workaround for getting xgettext to extract the translations from PHP heredoc syntax?
A somewhat related ticket has been opened on gettext project's ticket system: http://savannah.gnu.org/bugs/?27740 This indicates that support for the heredoc syntax could be improved?