mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 17:27:52 -06:00
fix the language code not correct issue
Change-Id: I73092fee16b2e1284ac79e63edbb3165c04d5650
This commit is contained in:
parent
0df07fcfde
commit
7a68cc56b2
2 changed files with 26 additions and 5 deletions
|
@ -2523,6 +2523,7 @@ void GUI_App::recreate_GUI(const wxString& msg_name)
|
||||||
dlg.Update(80, _L("Loading current presets") + dots);
|
dlg.Update(80, _L("Loading current presets") + dots);
|
||||||
load_current_presets();
|
load_current_presets();
|
||||||
mainframe->Show(true);
|
mainframe->Show(true);
|
||||||
|
mainframe->refresh_plugin_tips();
|
||||||
|
|
||||||
dlg.Update(90, _L("Loading a mode view") + dots);
|
dlg.Update(90, _L("Loading a mode view") + dots);
|
||||||
|
|
||||||
|
@ -3601,7 +3602,7 @@ bool GUI_App::load_language(wxString language, bool initial)
|
||||||
// Get the active language from PrusaSlicer.ini, or empty string if the key does not exist.
|
// Get the active language from PrusaSlicer.ini, or empty string if the key does not exist.
|
||||||
language = app_config->get("language");
|
language = app_config->get("language");
|
||||||
if (! language.empty())
|
if (! language.empty())
|
||||||
BOOST_LOG_TRIVIAL(trace) << boost::format("language provided by PrusaSlicer.ini: %1%") % language;
|
BOOST_LOG_TRIVIAL(trace) << boost::format("language provided by PBambuStudio.conf: %1%") % language;
|
||||||
else {
|
else {
|
||||||
// Get the system language.
|
// Get the system language.
|
||||||
const wxLanguage lang_system = wxLanguage(wxLocale::GetSystemLanguage());
|
const wxLanguage lang_system = wxLanguage(wxLocale::GetSystemLanguage());
|
||||||
|
@ -3609,7 +3610,7 @@ bool GUI_App::load_language(wxString language, bool initial)
|
||||||
m_language_info_system = wxLocale::GetLanguageInfo(lang_system);
|
m_language_info_system = wxLocale::GetLanguageInfo(lang_system);
|
||||||
BOOST_LOG_TRIVIAL(trace) << boost::format("System language detected (user locales and such): %1%") % m_language_info_system->CanonicalName.ToUTF8().data();
|
BOOST_LOG_TRIVIAL(trace) << boost::format("System language detected (user locales and such): %1%") % m_language_info_system->CanonicalName.ToUTF8().data();
|
||||||
// BBS set language to app config
|
// BBS set language to app config
|
||||||
app_config->set("language", m_language_info_system->CanonicalName.ToUTF8().data());
|
//app_config->set("language", m_language_info_system->CanonicalName.ToUTF8().data());
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
std::map<wxString, wxString> language_descptions = {
|
std::map<wxString, wxString> language_descptions = {
|
||||||
|
@ -3644,7 +3645,7 @@ bool GUI_App::load_language(wxString language, bool initial)
|
||||||
m_language_info_best = wxLocale::FindLanguageInfo(best_language);
|
m_language_info_best = wxLocale::FindLanguageInfo(best_language);
|
||||||
BOOST_LOG_TRIVIAL(trace) << boost::format("Best translation language detected (may be different from user locales): %1%") %
|
BOOST_LOG_TRIVIAL(trace) << boost::format("Best translation language detected (may be different from user locales): %1%") %
|
||||||
m_language_info_best->CanonicalName.ToUTF8().data();
|
m_language_info_best->CanonicalName.ToUTF8().data();
|
||||||
app_config->set("language", m_language_info_best->CanonicalName.ToUTF8().data());
|
//app_config->set("language", m_language_info_best->CanonicalName.ToUTF8().data());
|
||||||
}
|
}
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
wxString lc_all;
|
wxString lc_all;
|
||||||
|
@ -3716,6 +3717,27 @@ bool GUI_App::load_language(wxString language, bool initial)
|
||||||
language_info = wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH_UK);
|
language_info = wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH_UK);
|
||||||
app_config->set("language", language_info->CanonicalName.ToUTF8().data());
|
app_config->set("language", language_info->CanonicalName.ToUTF8().data());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// bbs supported languages
|
||||||
|
//TODO: use a global one with Preference
|
||||||
|
wxLanguage supported_languages[] {wxLANGUAGE_ENGLISH, wxLANGUAGE_CHINESE_SIMPLIFIED, wxLANGUAGE_GERMAN, wxLANGUAGE_FRENCH, wxLANGUAGE_SPANISH, wxLANGUAGE_SWEDISH, wxLANGUAGE_DUTCH };
|
||||||
|
std::string cur_language = app_config->get("language");
|
||||||
|
if (cur_language != "") {
|
||||||
|
//cleanup the language wrongly set before
|
||||||
|
const wxLanguageInfo *langinfo = nullptr;
|
||||||
|
bool embedded_language = false;
|
||||||
|
for (auto index = 0; index < 7; index++) {
|
||||||
|
langinfo = wxLocale::GetLanguageInfo(supported_languages[index]);
|
||||||
|
std::string temp_lan = langinfo->CanonicalName.ToUTF8().data();
|
||||||
|
if (cur_language == temp_lan) {
|
||||||
|
embedded_language = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!embedded_language)
|
||||||
|
app_config->erase("app", "language");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! wxLocale::IsAvailable(language_info->Language)) {
|
if (! wxLocale::IsAvailable(language_info->Language)) {
|
||||||
// Loading the language dictionary failed.
|
// Loading the language dictionary failed.
|
||||||
|
|
|
@ -634,7 +634,6 @@ wxWindow* PreferencesDialog::create_general_page()
|
||||||
// bbs supported languages
|
// bbs supported languages
|
||||||
wxLanguage supported_languages[]{wxLANGUAGE_ENGLISH, wxLANGUAGE_CHINESE_SIMPLIFIED, wxLANGUAGE_GERMAN, wxLANGUAGE_FRENCH, wxLANGUAGE_SPANISH, wxLANGUAGE_SWEDISH, wxLANGUAGE_DUTCH };
|
wxLanguage supported_languages[]{wxLANGUAGE_ENGLISH, wxLANGUAGE_CHINESE_SIMPLIFIED, wxLANGUAGE_GERMAN, wxLANGUAGE_FRENCH, wxLANGUAGE_SPANISH, wxLANGUAGE_SWEDISH, wxLANGUAGE_DUTCH };
|
||||||
|
|
||||||
|
|
||||||
auto translations = wxTranslations::Get()->GetAvailableTranslations(SLIC3R_APP_KEY);
|
auto translations = wxTranslations::Get()->GetAvailableTranslations(SLIC3R_APP_KEY);
|
||||||
std::vector<const wxLanguageInfo *> language_infos;
|
std::vector<const wxLanguageInfo *> language_infos;
|
||||||
language_infos.emplace_back(wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH));
|
language_infos.emplace_back(wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH));
|
||||||
|
@ -643,7 +642,7 @@ wxWindow* PreferencesDialog::create_general_page()
|
||||||
|
|
||||||
if (langinfo == nullptr) continue;
|
if (langinfo == nullptr) continue;
|
||||||
|
|
||||||
for (auto si = 0; si < sizeof(supported_languages); si++) {
|
for (auto si = 0; si < 7; si++) {
|
||||||
if (langinfo == wxLocale::GetLanguageInfo(supported_languages[si])) {
|
if (langinfo == wxLocale::GetLanguageInfo(supported_languages[si])) {
|
||||||
language_infos.emplace_back(langinfo);
|
language_infos.emplace_back(langinfo);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue