Skip to content

Commit

Permalink
Workaround wx-3.2 issues with translation lookup
Browse files Browse the repository at this point in the history
Special-case some problematic cases until wx-3.2.x includes the fixes
from wxWidgets/wxWidgets#24297

Better workaround for wx-3.2
  • Loading branch information
vslavik committed Feb 16, 2024
1 parent 634a225 commit f2f85a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/edapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <wx/intl.h>
#include <wx/ipc.h>
#include <wx/translation.h>
#include <wx/uilocale.h>

#include <iostream>
#include <fstream>
Expand Down Expand Up @@ -586,6 +587,19 @@ void PoeditApp::SetupLanguage()
wxTranslations *trans = new wxTranslations();
wxTranslations::Set(trans);

// workaround wx bug, see https://github.com/wxWidgets/wxWidgets/pull/24297
class PoeditTranslationsLoader : public wxFileTranslationsLoader
{
public:
wxArrayString GetAvailableTranslations(const wxString& domain) const override
{
auto all = wxFileTranslationsLoader::GetAvailableTranslations(domain);
all.push_back("en");
return all;
}
};
trans->SetLoader(new PoeditTranslationsLoader);

int language = wxLANGUAGE_DEFAULT;

#if NEED_CHOOSELANG_UI
Expand Down
2 changes: 2 additions & 0 deletions src/gexecute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ std::pair<long, wxArrayString> DoExecuteGettextImpl(const wxString& cmdline_)
env.env["OUTPUT_CHARSET"] = "UTF-8";

wxString lang = wxTranslations::Get()->GetBestTranslation("gettext-tools");
if ( lang.starts_with("en@") )
lang = "en"; // don't want things like en@blockquot
if ( !lang.empty() )
env.env["LANG"] = lang;
#endif // __WXOSX__ || __WXMSW__
Expand Down

0 comments on commit f2f85a9

Please sign in to comment.