php - 为什么 gettext 将空字符串转换为 .po 标题文本?

标签 php gettext

我在 PHP5 中设置了 gettext。在对字符集等进行了一些努力之后,我已经设法翻译了一些基本的字符串。现在我遇到了一个问题。翻译空字符串时,我希望得到未翻译的(空)字符串(如果我错了,请纠正我;))。

但是,我没有返回输入字符串,而是将 .PO 文件的标题作为翻译:

Project-Id-Version: PACKAGE VERSION Report-Msgid-Bugs-To: POT-Creation-Date: 2011-09-22 15:03+0200 PO-Revision-Date: 2011-09-22 15:37+0200 Last-Translator: timo Language-Team: English Language: en MIME-Version: 1.0 Content-Type: text/plain; charset=ASCII Content-Transfer-Encoding: 8bit Plural-Forms: nplurals=2; plural=(n != 1); 

当我使用文本编辑器查看 .mo 文件时,我看到标题似乎位于文件中的随机位置。我想给你看,但我无法粘贴文件。看起来有一个我的 msgid 列表,然后是标题,然后是我的 msgstr 列表

我使用以下命令生成 .mo 文件:
msgfmt -c -v -o en/LC_MESSAGES/messages.mo messages_en.po

在这个命令之后,我重新启动了我的网络服务器(lighttpd)。

我做错了什么,我该如何解决?

最佳答案

在搜索了一些不同的查询后,我偶然发现了这个网站:
http://framework.zend.com/issues/browse/ZF-2914
这里我发现空字符串到元信息的翻译其实是在specifications获取文本:

This also has another advantage, as the empty string in a PO file GNU gettext is usually translated into some system information attached to that particular MO file, and the empty string necessarily becomes the first in both the original and translated tables, making the system information very easy to find.

关于php - 为什么 gettext 将空字符串转换为 .po 标题文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7610144/

相关文章:

php - 限制用户访问管理面板

php - mysql_insert_id 使用安全吗?

php - PHP gettext 中的变量

php - Gettext:翻译带有 HTML 的字符串?

php - 使用 gettext 在 PHP 中添加对 i18n 的支持?

c++ - 完整的 C++ i18n gettext() "hello world"示例

php - 付款后PayUMoney支付网关错误

php: 从字符串中删除多余的 <br> 和标签

php - 如何使用 Doctrine2 中的级联选项让关联实体自动持久化?

java - 如何使用字段中的 linkText 提取 WebElements 并单击它