4

我正在尝试使用po2php将我的 .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

4

1 回答 1

0

你也可以试试梨包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 文件的内容作为关联数组。接下来,您需要一个函数来将此数组输出到文件中。看看这里的第二个答案:将数组打印到文件

于 2013-07-18T15:47:03.183 回答