Hi I am writing a sample code for i18n in c++. I referenced the following link.
The output displays the text in english. What is the problem here?
#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 start.cpp
$> xgettext -d start -o start.pot start.cpp
$> msginit --no-translator -l es_MX -o start_es.po -i start.pot
Created start_es.po.
I opened the start_es.po files using poedit.app and translated the text and saved
$> mkdir -p es/LC_MESSAGES
$> msgfmt -c -v -o ./es/LC_MESSAGES/start.mo start_es.po
1 translated message.
$>export LANG=es_MX
$> ./start