【问题标题】:How to convert .po to PHP array (Zend Framework) with Translate Toolkit?如何使用 Translate Toolkit 将 .po 转换为 PHP 数组(Zend 框架)?
【发布时间】:2013-07-18 15:16:49
【问题描述】:

我正在尝试使用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

【问题讨论】:

标签: php zend-framework internationalization gettext po


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2017-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-06
    • 1970-01-01
    相关资源
    最近更新 更多