【问题标题】:How to make a header for gettext .po files?如何为 gettext .po 文件制作标题?
【发布时间】:2010-01-14 17:18:18
【问题描述】:

我在 GNU Gettext manual 找到了 .po 文件的大部分结构。但是手册并没有说明如何设置标题。

如何为gettext .po 文件制作标题?

谢谢

【问题讨论】:

  • 标头告诉一些关于文件的信息,有点像 http 标头。我需要设置的那个告诉字符集我制作的文件。

标签: localization gnu gettext


【解决方案1】:

如果我是你,我会下载一个示例 .po 文件并使用常规文本编辑器查看内部。 标头包含以下信息:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#: src/link/to/my/src:67
msgid ""
msgstr ""
"Project-Id-Version: xxx\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-07-06 12:31-0500\n"
"PO-Revision-Date: 2011-05-27 22:37+0100\n"
"Last-Translator: My NAME<me@mydomain.com>\n"
"Language-Team: TEAM <team@TTEAM.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

然后,内部是这样组织的:

# This is a comment
# and another line of comment
msgid "This is my original string to translate"
msgstr "Translation goes here ... "

# TRANSLATED : Mon Jun 14 09:36:07 2010
# TRANSLATOR : MyName goes here... it's a comment
#: src/main/my/source/reference/:34  
msgid "Get started now!"
msgstr "Commencez dès maintenant!"

希望这会有所帮助...

【讨论】:

    【解决方案2】:

    发现设置字符集的方法很简单,只需将"Content-Type: text/plain; charset=utf8" 放入文件中。

    【讨论】:

      【解决方案3】:

      您可以使用的最小标题就是使用

      msgid ""
      msgstr "Content-Type: text/plain; charset=UTF-8"
      

      但在大多数情况下,您至少需要这样:

      msgid ""
      msgstr ""
      "Content-Type: text/plain; charset=UTF-8\n"
      "Language: en\n"
      "Plural-Forms: nplurals=2; plural=(n != 1);\n"
      

      您可以在那里拥有的所有其他内容(版权 cmets 或其他元数据)都是可选的。如果你不需要 plurar 支持,Plural-Forms 显然也不需要。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-06-07
        • 1970-01-01
        • 2012-08-20
        • 2012-03-29
        • 1970-01-01
        • 1970-01-01
        • 2012-04-26
        • 1970-01-01
        相关资源
        最近更新 更多