![](/img/trans.png)
[英]Command or option for the xgettext, msginit, msgfmt sequence for setting the MIME type?
[英]msgfmt error when generating .po file with xgettext and msginit
使用以下命令生成 a.po 文件時:
xgettext test.js -o test.pot -L JavaScript --from-code=UTF-8
msginit -i test.pot -o de.po --locale=de
我得到以下 header:
# Copyright (C) 2021 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# test <test@test.com>, 2021.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-04-16 11:39+0300\n"
"PO-Revision-Date: 2021-04-16 11:40+0300\n"
"Last-Translator: test <test@test.com>\n"
"Language-Team: German\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ASCII\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
使用msgfmt -cv /dev/null de.po
檢查此文件時,出現以下錯誤
msgfmt: /dev/null: warning: PO file header missing or invalid
warning: charset conversion will not work
msgfmt: found 1 fatal error
我將文件de.po
中的charset=ASCII
更改為charset=UTF-8
但得到了同樣的錯誤。 我正在使用 Ubuntu 服務器 20.04 和 gettext-tools 版本 0.19.8.1
如果您調用msgfmt -cv /dev/null de.po
,則/dev/null
是第一個輸入文件,這不是您想要的。 但難怪/dev/null
不包含有效的 PO header。
您可能想要的是: msgfmt -cvo /dev/null de.po
。
-o
表示/dev/null
是 output 文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.