如何将Zend本地化/翻译数组转换为gettext?

时间:2012-12-17 17:33:45

标签: zend-framework localization translation gettext zend-translate

我的多语种网站已成功使用Zend翻译的“数组”方法。

我想从该方法转换为“gettext”方法,因为我读过gettext是优越的。

我尝试使用http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/php2po.html,但无法让它发挥作用。

我认为这并不意味着将Zend数组作为输入。

我的Zend文件(有效)如下所示:

<?php

return array(    
    'choose your favorite stores' => 'Choose your %1$sfavorite stores%2$s',
    'P.S. If you ever have question' => 'P.S. If you ever have questions, %1$semail us%2$s any time.',
    'You can also find quick answer' => 'You can also find quick answers on our %1$sHelp page%2$s.',
    'Earn X cash' => '%1$sEarn 1-30%% cash back%2$s, get money-saving coupons, and find the best price on every purchase at %3$s2,500+ stores%4$s.'
);

(但它更长,我有多种语言,每种都在自己的PHP文件中。)

1 个答案:

答案 0 :(得分:0)

使用代码片段,您已经为我提供了转换功能。

$ php2po en.php en.po -t en.php 
processing 1 files...
[###########################################] 100%

$ cat en.po 
#. extracted from en.php, en.php
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-12-19 10:08+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.9.1-pre\n"

#: return+array%28-%3E%27choose+your+favorite+stores%27
msgid "Choose your %1$sfavorite stores%2$s"
msgstr "Choose your %1$sfavorite stores%2$s"

#: return+array%28-%3E%27P.S.+If+you+ever+have+question%27
msgid "P.S. If you ever have questions, %1$semail us%2$s any time."
msgstr "P.S. If you ever have questions, %1$semail us%2$s any time."

#: return+array%28-%3E%27You+can+also+find+quick+answer%27
msgid "You can also find quick answers on our %1$sHelp page%2$s."
msgstr "You can also find quick answers on our %1$sHelp page%2$s."

我正在使用git master中的翻译工具包版本,也许你应该尝试一下。