From 629da5302c771195f5f4420ef50183555b12eb76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Slavi=CC=81k?= Date: Thu, 1 Feb 2024 18:33:47 +0100 Subject: [PATCH] OTA updates: try to fix wrong requests on Unix Try to fix incorrect requests on Unix, where full locale (e.g. fr_FR) is used instead of just the catalog language name (e.g. fr). --- src/edapp.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/edapp.cpp b/src/edapp.cpp index 5627d70b9a..21d08fbff5 100644 --- a/src/edapp.cpp +++ b/src/edapp.cpp @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -656,6 +657,17 @@ void PoeditApp::SetupOTALanguageUpdate(wxTranslations *trans, const wxString& la else langMO.Replace("-", "_"); +#if defined(__UNIX__) && !defined(__WXOSX__) + // GetBestTranslation() can fall back to the locale there, so check if we ship this translation + auto avail = trans->GetAvailableTranslations("poedit"); + if (std::find(avail.begin(), avail.end(), lang) == avail.end()) + { + langMO = lang.BeforeFirst('_'); + if (std::find(avail.begin(), avail.end(), langMO) == avail.end()) + return; + } +#endif + auto version = str::to_utf8(GetMajorAppVersion()); // use downloaded OTA translations: