提高翻译:PO文件无法正常工作 [英] boost translate: po file not work

查看:204
本文介绍了提高翻译:PO文件无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用的boost ::区域设置,使多语言exe文件,但它不工作。
exe文件始终输出Hello World的。
怎么能输出您好?

我使用的示例code从的http://www.boost.org/doc/libs/1_53_0/libs/locale/doc/html/messages_formatting.html

 的#include<升压/ locale.hpp>
    #包括LT&;&iostream的GT;    使用命名空间std;
    使用空间boost ::区域设置;    诠释的main()
    {
        发电机根;        //指定词典的位置
        gen.add_messages_path(。);
        gen.add_messages_domain(你好);        //生成的语言环境,并灌输他们的iostream
        区域::全局(根());
        cout.imbue(区域设置());        //使用当前系统区域设置显示消息
        COUT<<翻译(的Hello World)<< ENDL;
    }

和做一个PO文件和MO文件。
PO文件是:

 #一些描述性标题。
#版权所有(C)年份包的版权所有者
#此文件,根据同一许可证的套餐包分配。
#第一作者和LT; EMAIL @地址>中的一年。

MSGID
msgstr
项目-ID-版本:消息的\\ n
报告-MSGID-错误,可以:\\ n
POT-创建日期:2013年4月26日20:50 + 0800 \\ n
PO-修订-日期:2013年4月26日21:44 + 0800 \\ n
最后一译者:\\ N
语言特攻队:语言< LL@li.org> \\ N
MIME-版本:1.0 \\ n
内容类型:text / plain的;字符集= UTF-8 \\ n
内容传输编码:8位\\ n
X-发生器:poEdit的1.5.5 \\ n
X-poEdit的-SourceCharset:UTF-8 \\ n#:main.cpp中:21
MSGID的Hello World
msgstr您好


解决方案

林年初boost_locale过,这是我如何使其发挥作用...


  1. 首先确保您的.mo文件正是命名为域您指的是,在这种情况下hello.mo


  2. 把文件的.mo到正确的文件结构,例如,如果你想翻译成西班牙文,这将是./es_ES/LC_MESSAGES/hello.mo


  3. 请确保您实例全局区域设置这样,
    区域::全局(根(es_ES.UTF-8));


希望这有助于。

I was used boost::locale to make a multilanguage exe, but it doesn't work. The exe always output "Hello World". How can it output "您好"?

I used the example code from http://www.boost.org/doc/libs/1_53_0/libs/locale/doc/html/messages_formatting.html

    #include <boost/locale.hpp>
    #include <iostream>

    using namespace std;
    using namespace boost::locale;

    int main()
    {
        generator gen;

        // Specify location of dictionaries
        gen.add_messages_path(".");
        gen.add_messages_domain("hello");

        // Generate locales and imbue them to iostream
        locale::global(gen(""));
        cout.imbue(locale());

        // Display a message using current system locale
        cout << translate("Hello World") << endl;
    }

And make a po file and a mo file. Po file is:

# 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.
#
msgid ""
msgstr ""
"Project-Id-Version: messages\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-04-26 20:50+0800\n"
"PO-Revision-Date: 2013-04-26 21:44+0800\n"
"Last-Translator: \n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.5.5\n"
"X-Poedit-SourceCharset: UTF-8\n"

#: main.cpp:21
msgid "Hello World"
msgstr "您好"

解决方案

Im beginning with boost_locale too, here is how i make it work...

  1. First make sure your .mo file is named exactly as the domain your refering to, in this case hello.mo

  2. Put the .mo file into the correct file structure, for example if your trying to translate to spanish this would be ./es_ES/LC_MESSAGES/hello.mo

  3. Make sure you instantiate the global locale like this, locale::global(gen("es_ES.UTF-8"));

Hope this helps.

这篇关于提高翻译:PO文件无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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