| #define TR(S) boost::locale::translate(S).str() |
| const std::string strDefaultLangId( "en" ); |
| int main( int argc, char * argv[] ) |
| { |
| using namespace std; |
| using namespace boost::locale; |
| int exitCode = EXIT_SUCCESS; |
| try |
| { |
| generator gen; |
| gen.add_messages_path("g:\\source\\boost_locale\\languages\\"); |
| gen.add_messages_domain("messages"); |
| std::string language( argc == 2 ? argv[1] : strDefaultLangId.c_str() ); |
| std::locale loc = gen( language ); |
| locale::global( loc ); |
| std::wstring s = TR(L"hello world"); |
| wcout << s << endl; |
| } |
| catch( exception& e ) |
| { |
| cout << "Error : " << e.what() << endl; |
| exitCode = EXIT_FAILURE; |
| } |
| catch( ... ) |
| { |
| cout << "Unknown error" << endl; |
| exitCode = EXIT_FAILURE; |
| } |
| return exitCode; |
| } The path to the file with the russian language: "g:\source\boost_locale\languages\ru\LC_MESSAGES\messages.mo" What could be wrong? * Is it necessary to use any backends? * Is it yet necessary to call imbue on the stream? But I'd like avoid it because I am going to write the log using glog. |