1
こんにちは私は、i18nのサンプルコードをC++で書いています。私は以下を参照しましたlink。C++ GNU xgettexの実行をトレースする方法は?
出力にはテキストが英語で表示されます。ここでの問題は何ですか?
#include "start.hpp"
#include <iostream>
#include <locale.h>
#include "/opt/local/share/gettext/gettext.h"
using namespace std;
int main(int argc, char *argv[]){
char* cwd = getenv("PWD");
std::cout << "getenv(PWD): " << (cwd?cwd:"NULL") << std::endl;
char* l = getenv("LANG");
std::cout << "getenv(LANG): " << (l?l:"NULL") << std::endl;
char* s = setlocale(LC_ALL, "");
std::cout << "setlocale(): " << (s?s:"NULL") << std::endl;
std::cout << "bindtextdomain(): " << bindtextdomain("hello", cwd) << std::endl;
std::cout << "textdomain(): " << textdomain("hello") << std::endl;
std::cout << gettext("hello, world!") << std::endl;
return 0;
}
$> G ++ -o start.cppに
$を開始>にxgettextは-o start.potのstart.cppに
$> msginitを開始-d - 翻訳なし-l es_MX -o start_es.po -i start.pot
作成されたstart_es.po。
私はpoedit.appを使用してstart_es.poファイルを開いて、テキストを翻訳し、
$>ます。mkdir -p ES/LC_MESSAGES
$> msgfmt -c -v -oを保存./es/LC_MESSAGES/start.mo start_es.po
1つのメッセージ。
$>輸出LANG = es_MX
$> startと