Completo C ++ i18n gettext () exemplo "hello world"

Eu estou procurando um i18n completogettext() olá mundo exemplo. Eu comecei um script baseado emUm tutorial sobre suporte a idiomas nativos usando o gettext do GNU por G. Mohanty. Eu estou usando Linux e G + +.

Código:

<code>cat >hellogt.cxx <<EOF
// hellogt.cxx
#include <libintl.h>
#include <locale.h>
#include <iostream>
#include <cstdlib>
int main (){
    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("hellogt", cwd) << std::endl;
    std::cout << "textdomain(): " << textdomain( "hellogt") << std::endl;
    std::cout << gettext("hello, world!") << std::endl;
}
EOF
g++ -ohellogt hellogt.cxx
xgettext -d hellogt -o hellogt.pot hellogt.cxx
msginit --no-translator -l es_MX -o hellogt_spanish.po -i hellogt.pot
sed --in-place hellogt_spanish.po --expression='/#: /,$ s/""/"hola mundo"/'
sed --in-place hellogt_spanish.po --expression='s/PACKAGE VERSION/hellogt 1.0/'
mkdir -p ./es_MX/LC_MESSAGES
msgfmt -c -v -o ./es_MX/LC_MESSAGES/hellogt.mo hellogt_spanish.po
export LANG=es_MX
ls -l $PWD/es_MX/LC_MESSAGES/hellogt.mo
./hellogt
strace -e trace=open ./hellogt
</code>

O programa compila, o texto é extraído, o arquivo espanhol é criado, modificado e o binário criado, mas o hellogt ainda exibe o inglês. O rastreio não mostra nenhuma evidência de procurar no diretório de trabalho atual por es_MX nem quaisquer referências ao diretório LC_MESSAGES.

questionAnswers(3)

yourAnswerToTheQuestion