1

首先,我如何使以下示例工作(来自 boost 网站):

        #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 文件但仍然无效)。

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

我怎样才能做到这一点?

谢谢。

4

1 回答 1

2

boost translate: po 文件不起作用可能会有所帮助。

最令人困惑的步骤是:

2. 将 .mo 文件放入正确的文件结构中,例如,如果您尝试翻译成西班牙语,这将是 ./es_ES/LC_MESSAGES/hello.mo

它是GNU 'gettext' 实用程序的包装器。手册也很有用。

于 2014-04-02T13:10:24.087 回答