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
  • Loading branch information
vslavik committed Feb 15, 2024
1 parent 634a225 commit 664ea1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 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 @@ -618,6 +619,15 @@ void PoeditApp::SetupLanguage()
#endif
}

// workaround wx bug, see https://github.com/wxWidgets/wxWidgets/pull/24297
if (language == wxLANGUAGE_DEFAULT && trans->GetBestTranslation("poedit") == "en_GB")
{
// only use en_GB if it is actually appropriate
auto pref = wxUILocale::GetPreferredUILanguages();
if (std::find(pref.begin(), pref.end(), "en-GB") == pref.end()) // not really requested
trans->SetLanguage("en");
}

trans->AddStdCatalog();
trans->AddCatalog("poedit");

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 664ea1b

Please sign in to comment.