默认情况下, xgettext 会忽略评论栏中找到的所有关键字。
<?php // file.php
echo _('This text will be found');
//_('This text will be ignored');
是否可以覆盖此行为?我尝试添加//_
作为关键字,但这也失败了。评论似乎优先于关键字:
xgettext -o output.po --language=PHP -k_ -k//_ file.php
感谢您的帮助!
答案 0 :(得分:3)
看来,xgettext过滤了评论,我不知道如何避免这种情况。但是,作为替代解决方案,您可以在将文件提供给xgettext之前使用 sed 替换注释:
sed 's/\/\/_/_/g' file.php | xgettext -o output.po --language=PHP -