From f2f85a9291860722e55787e8788252c5a859ba6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Slavi=CC=81k?= Date: Thu, 15 Feb 2024 14:23:27 +0100 Subject: [PATCH] Workaround wx-3.2 issues with translation lookup Special-case some problematic cases until wx-3.2.x includes the fixes from https://github.com/wxWidgets/wxWidgets/pull/24297 Better workaround for wx-3.2 --- src/edapp.cpp | 14 ++++++++++++++ src/gexecute.cpp | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/edapp.cpp b/src/edapp.cpp index fbf322d989..97ea69a403 100644 --- a/src/edapp.cpp +++ b/src/edapp.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -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 diff --git a/src/gexecute.cpp b/src/gexecute.cpp index 6292ba74fd..e7cefc6151 100644 --- a/src/gexecute.cpp +++ b/src/gexecute.cpp @@ -128,6 +128,8 @@ std::pair 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__