1
다국어 exe를 만들기 위해 boost :: locale을 사용했지만 동작하지 않습니다. exe는 항상 "Hello World"를 출력합니다. 어떻게 "您好"를 출력 할 수 있습니까? boost 번역 : po 파일이 작동하지 않습니다
나는 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;
}
에서 예제 코드를 사용 그리고 PO 파일과 모 파일을 확인하십시오. 포 파일은 다음과 같습니다도 여기 boost_locale와
# 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 protected]>, 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 <[email protected]>\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 "您好"
감사합니다. 나는 그것을 풀었고, 나는 cppcms의 소스 코드를 보았다. – Alberl