From 2e73a759516071b201e6de6b8329fa4d3cbfab43 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Mon, 30 Nov 2020 11:57:16 +0100 Subject: [PATCH] Linux specific fix for switching languages: PrusaSlicer 2.3 forces en_GB locale when switching to English from the user interface, while often Linux users have just en_US locales configured. With this commit the user will have to select English (U.S.) or English (U.K.). Usually English (U.S.) will work. Vojtech is scared to touch the code for the other platforms (Windows and Mac) as the language switching has been reworked multiple times and it is quite fragile. --- src/slic3r/GUI/GUI_App.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 7a8b78664..7a0befee5 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1278,6 +1278,11 @@ bool GUI_App::select_language() wxArrayString translations = wxTranslations::Get()->GetAvailableTranslations(SLIC3R_APP_KEY); std::vector language_infos; language_infos.emplace_back(wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH)); +#ifdef __linux__ + // wxWidgets consider the default English locale to be en_GB, which is often missing on Linux. + // Thus we offer en_US on Linux as well. + language_infos.emplace_back(wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH_US)); +#endif // __linux__ for (size_t i = 0; i < translations.GetCount(); ++ i) { const wxLanguageInfo *langinfo = wxLocale::FindLanguageInfo(translations[i]); if (langinfo != nullptr) @@ -1306,6 +1311,13 @@ bool GUI_App::select_language() if (language_infos[i]->CanonicalName.BeforeFirst('_') == "en") // This will be the default selection if the active language does not match any dictionary. init_selection_default = i; +#ifdef __linux__ + // wxWidgets consider the default English locale to be en_GB, which is often missing on Linux. + // Thus we make the distintion between "en_US" and "en_GB" clear. + if (language_infos[i]->CanonicalName == "en_GB" && language_infos[i]->Description == "English") + names.Add("English (U.K.)"); + else +#endif // __linux__ names.Add(language_infos[i]->Description); } if (init_selection == -1)