【问题标题】:PO file header missing or invalidPO 文件头丢失或无效
【发布时间】:2020-04-27 11:47:34
【问题描述】:

我正在尝试将 en_SG 翻译添加到 R 包中,但遇到了 gettext 错误,并且我没有看到任何有关问题的来源:

list.files('po')
# [1] "R-myPkg.pot"
# [2] "R-en_SG.po"
tools::update_pkg_po('.')

有输出:

  R-en_SG:. done.
msgfmt: po/R-en_SG.po: warning: PO file header missing or invalid
                       warning: charset conversion will not work
msgfmt: found 1 fatal error
Warning in tools::update_pkg_po(".") :
  running msgfmt on R-en_SG.po failed
  R-en@quot:
2 translated messages.

我到底错过了什么?

【问题讨论】:

    标签: r gettext po msgfmt


    【解决方案1】:

    PO 文件应该有一个“标题”,它实际上是一个带有空字符串翻译的条目。它看起来像这样:

    # German translations for qgoda package.
    # Copyright (C) 2018 Guido Flohr <http://www.guido-flohr.net>
    # This file is distributed under the same license as the qgoda package.
    # Guido Flohr <guido.flohr@dontspam.me>, 2018.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: qgoda 0.1.1\n"
    "Report-Msgid-Bugs-To: Guido Flohr <guido.flohr@dontspam.me>\n"
    "POT-Creation-Date: 2018-05-16 20:36+0300\n"
    "PO-Revision-Date: 2018-05-16 20:37+0300\n"
    "Last-Translator: Guido Flohr <guido.flohr@donstspam.me>\n"
    "Language-Team: German\n"
    "Language: de\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=UTF-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Plural-Forms: nplurals=2; plural=(n != 1);\n"
    

    此标头包含目录的元信息,例如Content-Type 标头字段中的 PO 文件的编码。您缺少此标头字段。

    我不知道您如何生成文件po/R-en_SG.po,但您必须确保它至少包含一个最小的 PO 标头。如有疑问,您必须手动添加。

    【讨论】:

    • 当然!出于某种原因,我希望我使用一个工具来为我制作这个。谢谢提醒
    猜你喜欢
    • 1970-01-01
    • 2021-02-10
    • 2013-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-19
    • 2012-11-25
    • 1970-01-01
    相关资源
    最近更新 更多