2013-10-22 54 views
1

首先如何让我下面的例子中工作(从提升网站)的:提升区域C++ - 理解基础

 #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; 
     } 

(尝试创建一个hello.mo文件,但仍然没有工作)。

基本上我想要做的是能够cout一个字符串,如:“操作”, ,然后根据file1/file2它将打印字符串值在该特定文件的id:操作。

我该怎么办呢?

谢谢。

回答

2

boost translate: po file not work可能会有所帮助。

最令人困惑的步骤是:

2.将文件的.mo到正确的文件结构,例如,如果你想翻译成西班牙语,这将是./es_ES/LC_MESSAGES/hello.mo

它是GNU 'gettext' utilities的包装。该手册也很有用。