用于设置MIME类型的xgettext,msginit,msgfmt序列的命令或选项? [英] Command or option for the xgettext, msginit, msgfmt sequence for setting the MIME type?

查看:55
本文介绍了用于设置MIME类型的xgettext,msginit,msgfmt序列的命令或选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

msgfmt无效的多字节序列"错误可通过在模板文件中手动编辑MIME Con​​tent-Type字符集进行更正.是否有一些命令或选项可用于设置MIME类型的xgettext,msginit,msgfmt序列?

msgfmt "invalid multibyte sequence" error on a Polish text is corrected by manually editing the MIME Content-Type charset in the template file. Is there some command or option for the xgettext, msginit, msgfmt sequence for setting the MIME type?

cat >plt.cxx <<EOF
// plt.cxx
#include <libintl.h>
#include <locale.h>
#include <iostream>
int main (){
    setlocale(LC_ALL, "");
    bindtextdomain("plt", ".");
    textdomain( "plt");
    std::cout << gettext("Invalid input. Enter a string at least 20 characters long.") << std::endl;
}
EOF
g++ -o plt plt.cxx
xgettext --package-name plt --package-version 1.2 --default-domain plt --output plt.pot plt.cxx
sed --in-place plt.pot --expression='s/CHARSET/UTF-8/'
msginit --no-translator --locale pl_PL --output-file plt_polish.po --input plt.pot
sed --in-place plt_polish.po --expression='/#: /,$ s/""/"Nieprawidłowo wprowadzone dane. Wprowadź ciąg przynajmniej 20 znaków."/'
mkdir --parents ./pl_PL.utf8/LC_MESSAGES
msgfmt --check --verbose --output-file ./pl_PL.utf8/LC_MESSAGES/plt.mo plt_polish.po
LANGUAGE=pl_PL.utf8 ./plt

推荐答案

只需提供完整的语言环境名称,msginit即可正确设置字符集

Just give full locale name and msginit will set charset correctly

msginit --no-translator --input=xx.pot --locale=ru_RU.UTF-8

产生

"Language: ru\n"
"Content-Type: text/plain; charset=UTF-8\n"

这篇关于用于设置MIME类型的xgettext,msginit,msgfmt序列的命令或选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆