mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-04-06 00:32:05 +02:00
Fix: generic locale fallback on all platforms when language is unavai… (#12948)
Fix: generic locale fallback on all platforms when language is unavailable Move the locale fallback chain out of the #ifdef __linux__ block so it applies on macOS and Windows too. Add a base-language fallback step that strips the region code (e.g. en_IL -> en) before trying the full fallback chain (current locale, system, best, en_US, en_UK). Previously, if wxLocale::IsAvailable() failed on non-Linux, the app would show an error and exit. Now it gracefully falls back to a working locale. Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
@@ -6424,7 +6424,22 @@ bool GUI_App::load_language(wxString language, bool initial)
|
||||
% original_lang % locale_language_info->CanonicalName.ToUTF8().data();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Try base language without region (e.g., "en" from "en_IL") on all platforms
|
||||
if (locale_language_info == nullptr || !wxLocale::IsAvailable(locale_language_info->Language)) {
|
||||
wxString base_lang = requested_language_code.BeforeFirst('_');
|
||||
if (base_lang != requested_language_code) {
|
||||
const wxLanguageInfo *base_info = wxLocale::FindLanguageInfo(base_lang);
|
||||
if (base_info && wxLocale::IsAvailable(base_info->Language)) {
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("Locale %1% not available. Falling back to base language %2%.")
|
||||
% requested_language_code.ToUTF8().data() % base_info->CanonicalName.ToUTF8().data();
|
||||
locale_language_info = base_info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generic fallback chain for all platforms
|
||||
if (locale_language_info == nullptr || !wxLocale::IsAvailable(locale_language_info->Language)) {
|
||||
auto try_locale = [](const wxLanguageInfo* candidate) -> const wxLanguageInfo* {
|
||||
return (candidate && wxLocale::IsAvailable(candidate->Language)) ? candidate : nullptr;
|
||||
@@ -6441,7 +6456,6 @@ bool GUI_App::load_language(wxString language, bool initial)
|
||||
locale_language_info = fallback_locale_info;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (initial) {
|
||||
// bbs supported languages
|
||||
|
||||
Reference in New Issue
Block a user