我正在尝试使用po2php http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/php2po.html将我的 .po 文件转换为 Zend php 翻译数组。
我只是想这样做:$ po2php translations.po translations.php
,但这会导致我不明白的错误:po2php: warning: Couldn't handle input file translations.po: don't know what to do with input format .po, no template file
.
我不知道模板文件是什么,为什么要提供它?
更新:我也尝试过$ po2php translations.po translations.php -t messages.pot
,但这对我没有帮助,它显示了几乎相同的错误:po2php: warning: Couldn't handle input file translations.po: don't know what to do with input format .po, template format .pot
.
你也可以试试梨包文件_获取文本 http://pear.php.net/package/File_Gettext。在这里阅读更多内容:https://github.com/pear/File_Gettext https://github.com/pear/File_Gettext
代码如下所示(未测试):
include_once 'File/Gettext/PO.php';
$poFile = new File_Gettext_PO();
$poFile->load('PATH_TO/translations.po');
print_r($poFile->strings);
$poFile->strings
应包含 po 文件的内容作为关联数组。接下来,您需要一个函数来将该数组输出到文件中。看看这里的第二个答案:将数组打印到文件 https://stackoverflow.com/questions/2628798/print-array-to-a-file
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)