【问题标题】:wxTextEntryDialog translation of OK and CancelwxTextEntryDialog 翻译OK和Cancel
【发布时间】:2014-11-06 20:30:12
【问题描述】:

除了 wxTextEntryDialog 对话框中包含的“确定”和“取消”之外,我的应用程序的所有翻译都运行良好。 我怎样才能正确翻译这些内容? 使用 OK 和 Cancel 时,即使 wxMessageBox 也能正常工作,但 wxTextEntryDialog 似乎不能翻译成任何其他语言。

我在我的代码中使用了以下 sn-ps 语言分配:

wxLocale m_locale; // locale we'll be using (this is defined in the header file of my app)
// Within the source
lang = wxLANGUAGE_CHINESE_SIMPLIFIED; // for e.g. could be any language

m_locale.Init(lang);
    // normally this wouldn't be necessary as the catalog files would be found in the default locations, but when the program is not installed the
    // catalogs are in the build directory where we wouldn't find them by default
    wxLocale::AddCatalogLookupPathPrefix(wxT(LanguagePath));// add path of install
    // Initialize the catalogs we'll be using
 m_locale.AddCatalog(_("messages"));   // .mo file generated by my application language specific .mo file 

提前感谢您的帮助。

【问题讨论】:

    标签: c++ visual-c++ translation wxwidgets


    【解决方案1】:

    您对Init() 的调用是否成功?你真的应该检查它的返回值,它可能没有找到wxstd.mo,它包含wxWidgets 中使用的所有消息的翻译,因为你在设置查找路径之前调用它。你需要

    1. 确保wxstd.mo 在您的目录路径中可用。
    2. 设置此路径后调用Init()
    3. 检查其返回值。

    【讨论】:

      【解决方案2】:

      感谢@VZ。为了洞察力。您的方法帮助我更好地调试了我的应用程序,即我能够通过检查返回值看到 Init() 没有成功。有了这个,我能够进一步调查。此外,wxstd.mo 只是默认的 .po 生成的 .mo(没有翻译,我为什么需要这个?)

      解决方案:我必须添加 wxWidgets 翻译文件,即从 <wxdir>/locale/ 中包含的 .po 文件生成的 .mo 目录文件。我不得不将它们复制到与我的messages.mo 相同的目录中。因此,简体中文的工作代码如下所示。

      wxLocale m_locale; // locale we'll be using (this is defined in the header file of my app)
      // Within the source
      lang = wxLANGUAGE_CHINESE_SIMPLIFIED; // for e.g. could be any language
      
      wxLocale::AddCatalogLookupPathPrefix(wxT(LanguagePath));// add path of install
      
      m_locale.Init(lang, wxLOCALE_CONV_ENCODING);
      
      m_locale.AddCatalog(wxT("zh_CN"));  // This is the .mo file I generated from the wxWidgets .po files
          // Initialize the catalogs we'll be using
       m_locale.AddCatalog(_("messages"));   // .mo file generated by my application language specific .mo file 
      

      我没有出于某种目的包含检查,因为我希望应用程序以英语运行,即使该语言不受支持但我确实将其用于调试

      【讨论】:

        猜你喜欢
        • 2016-05-30
        • 1970-01-01
        • 2018-04-19
        • 2023-03-31
        • 2016-12-25
        • 2023-04-03
        • 2012-05-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多