From 664ea1bb0d568c14936b774be79b82706620edd7 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 --- src/edapp.cpp | 10 ++++++++++ src/gexecute.cpp | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/edapp.cpp b/src/edapp.cpp index fbf322d989..24a1926cf6 100644 --- a/src/edapp.cpp +++ b/src/edapp.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -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"); 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__