diff --git a/src/slic3r/GUI/OG_CustomCtrl.cpp b/src/slic3r/GUI/OG_CustomCtrl.cpp index 4ff7e0778..579db938e 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.cpp +++ b/src/slic3r/GUI/OG_CustomCtrl.cpp @@ -351,8 +351,6 @@ void OG_CustomCtrl::OnMotion(wxMouseEvent& event) wxString tooltip; std::string markdowntip; - wxString language = wxGetApp().app_config->get("language"); - // BBS: markdown tip CtrlLine* focusedLine = nullptr; // BBS diff --git a/src/slic3r/GUI/Project.cpp b/src/slic3r/GUI/Project.cpp index 1505ae8f0..814040f52 100644 --- a/src/slic3r/GUI/Project.cpp +++ b/src/slic3r/GUI/Project.cpp @@ -43,7 +43,7 @@ const std::vector license_list = { ProjectPanel::ProjectPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) : wxPanel(parent, id, pos, size, style) { m_project_home_url = wxString::Format("file://%s/web/model/index.html", from_u8(resources_dir())); - std::string strlang = wxGetApp().app_config->get("language"); + wxString strlang = wxGetApp().current_language_code_safe(); if (strlang != "") m_project_home_url = wxString::Format("file://%s/web/model/index.html?lang=%s", from_u8(resources_dir()), strlang); diff --git a/src/slic3r/GUI/SendSystemInfoDialog.cpp b/src/slic3r/GUI/SendSystemInfoDialog.cpp index 00dcf5d89..b8fe67dd2 100644 --- a/src/slic3r/GUI/SendSystemInfoDialog.cpp +++ b/src/slic3r/GUI/SendSystemInfoDialog.cpp @@ -437,7 +437,7 @@ static std::string generate_system_info_json() ); #endif // __WXGTK__ data_node.put("SystemLanguage", sys_language); - data_node.put("TranslationLanguage: ", wxGetApp().app_config->get("language")); + data_node.put("TranslationLanguage: ", wxGetApp().current_language_code_safe()); pt::ptree hw_node; diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index da8edef9b..306b7494a 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -171,8 +171,8 @@ wxString GuideFrame::SetStartPage(GuidePage startpage, bool load) TargetUrl = from_u8((boost::filesystem::path(resources_dir()) / "web/guide/21/index.html").make_preferred().string()); } - std::string strlang = wxGetApp().app_config->get("language"); - BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(", strlang=%1%")%strlang; + wxString strlang = wxGetApp().current_language_code_safe(); + BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(", strlang=%1%") % into_u8(strlang); if (strlang != "") TargetUrl = wxString::Format("%s?lang=%s", w2s(TargetUrl), strlang); diff --git a/src/slic3r/GUI/WebUserLoginDialog.cpp b/src/slic3r/GUI/WebUserLoginDialog.cpp index 9c47fae46..92c279758 100644 --- a/src/slic3r/GUI/WebUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebUserLoginDialog.cpp @@ -37,25 +37,12 @@ BEGIN_EVENT_TABLE(ZUserLogin, wxDialog) EVT_TIMER(NETWORK_OFFLINE_TIMER_ID, ZUserLogin::OnTimer) END_EVENT_TABLE() -string &replace_str(string &str, const string &to_replaced, const string &newchars) -{ - for (string::size_type pos(0); pos != string::npos; pos += newchars.length()) { - pos = str.find(to_replaced, pos); - if (pos != string::npos) - str.replace(pos, to_replaced.length(), newchars); - else - break; - } - return str; -} - int ZUserLogin::web_sequence_id = 20000; ZUserLogin::ZUserLogin() : wxDialog((wxWindow *) (wxGetApp().mainframe), wxID_ANY, "BambuStudio") { SetBackgroundColour(*wxWHITE); // Url - AppConfig * config = wxGetApp().app_config; NetworkAgent* agent = wxGetApp().getAgent(); if (!agent) { std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str(); @@ -92,9 +79,9 @@ ZUserLogin::ZUserLogin() : wxDialog((wxWindow *) (wxGetApp().mainframe), wxID_AN TargetUrl = host_url + "/sign-in"; m_networkOk = false; - std::string strlang = config->get("language"); + wxString strlang = wxGetApp().current_language_code_safe(); if (strlang != "") { - replace_str(strlang, "_", "-"); + strlang.Replace("_", "-"); TargetUrl = host_url + "/" + strlang + "/sign-in"; } diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index 919699b96..b1b06756f 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -33,7 +33,7 @@ WebViewPanel::WebViewPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize) { wxString url = wxString::Format("file://%s/web/homepage/index.html", from_u8(resources_dir())); - std::string strlang = wxGetApp().app_config->get("language"); + wxString strlang = wxGetApp().current_language_code_safe(); if (strlang != "") url = wxString::Format("file://%s/web/homepage/index.html?lang=%s", from_u8(resources_dir()), strlang); @@ -505,7 +505,7 @@ int WebViewPanel::get_model_mall_detail_url(std::string *url, std::string id) { // https://makerhub-qa.bambu-lab.com/en/models/2077 std::string h = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code()); - auto l = wxGetApp().app_config->get("language"); + auto l = wxGetApp().current_language_code_safe(); if (auto n = l.find('_'); n != std::string::npos) l = l.substr(0, n); *url = (boost::format("%1%%2%/models/%3%") % h % l % id).str();