This might be a simple question but I'm struggling with it for quite a time, that's why I hope that one of you may help me.
I'm trying to get Boost locale's function translate
to work. Referring this example code:
#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;
}
Let's say I want to translate into german. Do I have to pass
"de"
likelocale::global(gen("de"));
?I read something of
*.po
and*.mo
files. Can someone explain me how this all works?
Thanks in advance.
In your case it could be
locale::global(gen("de_DE.UTF-8"));
I would recommend you these sources for further information: