Skip to content

Commit

Permalink
Better workaround for wx-3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
vslavik committed Feb 16, 2024
1 parent db3366e commit 08ec182
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/edapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,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 Expand Up @@ -619,15 +632,6 @@ 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

0 comments on commit 08ec182

Please sign in to comment.