From 08ec18267f109c7f11361c2255b9b4c802a968d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Slavi=CC=81k?= Date: Fri, 16 Feb 2024 15:57:20 +0100 Subject: [PATCH] Better workaround for wx-3.2 --- src/edapp.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/edapp.cpp b/src/edapp.cpp index 24a1926cf6..97ea69a403 100644 --- a/src/edapp.cpp +++ b/src/edapp.cpp @@ -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 @@ -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");