ENH: Use Language of Studio
JIRA: none Change-Id: I18165b519b76cd195aafbed0ad5cf29eb43b01af
This commit is contained in:
parent
85840593fc
commit
6a9fd6678e
|
@ -55,7 +55,7 @@ WebViewPanel::WebViewPanel(wxWindow *parent)
|
|||
wxString UrlLeft = wxString::Format("file://%s/web/homepage3/left.html", from_u8(resources_dir()));
|
||||
wxString UrlRight = wxString::Format("file://%s/web/homepage3/home.html", from_u8(resources_dir()));
|
||||
|
||||
wxString strlang = wxGetApp().current_language_code_safe();
|
||||
wxString strlang = GetStudioLanguage();
|
||||
if (strlang != "")
|
||||
{
|
||||
UrlLeft = wxString::Format("file://%s/web/homepage3/left.html?lang=%s", from_u8(resources_dir()), strlang);
|
||||
|
@ -335,7 +335,7 @@ void WebViewPanel::ResetWholePage()
|
|||
wxString WebViewPanel::MakeDisconnectUrl(std::string MenuName)
|
||||
{
|
||||
wxString UrlDisconnect = wxString::Format("file://%s/web/homepage3/disconnect.html?menu=%s", from_u8(resources_dir()), MenuName);
|
||||
wxString strlang = wxGetApp().current_language_code_safe();
|
||||
wxString strlang = GetStudioLanguage();
|
||||
if (strlang != "") { UrlDisconnect = wxString::Format("file://%s/web/homepage3/disconnect.html?menu=%s&lang=%s", from_u8(resources_dir()), MenuName, strlang); }
|
||||
|
||||
return UrlDisconnect;
|
||||
|
@ -1088,8 +1088,7 @@ void WebViewPanel::SetMakerworldPageLoginStatus(bool login ,wxString ticket)
|
|||
//std::cout << "Not Find agreeBackUrl" << std::endl;
|
||||
auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
|
||||
|
||||
wxString language_code = wxGetApp().current_language_code().BeforeFirst('_');
|
||||
language_code = language_code.ToStdString();
|
||||
wxString language_code = wxString::FromUTF8(GetStudioLanguage()).BeforeFirst('_');
|
||||
|
||||
mw_currenturl = (boost::format("%1%%2%/studio/webview?from=bambustudio") % host % language_code.mb_str()).str();
|
||||
}
|
||||
|
@ -1120,17 +1119,6 @@ void WebViewPanel::get_4u_staffpick(int seed, int limit, std::function<void(std:
|
|||
int ret = agent->get_mw_user_4ulist(seed,limit,callback);
|
||||
}
|
||||
|
||||
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().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();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WebViewPanel::ShowUserPrintTask(bool bShow, bool bForce)
|
||||
{
|
||||
std::string phShow = wxGetApp().app_config->get("app", "show_print_history");
|
||||
|
@ -1183,8 +1171,7 @@ void WebViewPanel::ShowUserPrintTask(bool bShow, bool bForce)
|
|||
//refresh url
|
||||
auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
|
||||
|
||||
wxString language_code = wxGetApp().current_language_code().BeforeFirst('_');
|
||||
language_code = language_code.ToStdString();
|
||||
wxString language_code = wxString::FromUTF8(GetStudioLanguage()).BeforeFirst('_');
|
||||
|
||||
wxString mw_OffUrl = (boost::format("%1%%2%/studio/print-history?from=bambustudio") % host % language_code.mb_str()).str();
|
||||
wxString Finalurl = wxString::Format("%sapi/sign-out?to=%s", host, UrlEncode("about:blank"));
|
||||
|
@ -1687,8 +1674,7 @@ void WebViewPanel::OpenMakerworldSearchPage(std::string KeyWord)
|
|||
|
||||
auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
|
||||
|
||||
wxString language_code = wxGetApp().current_language_code().BeforeFirst('_');
|
||||
language_code = language_code.ToStdString();
|
||||
wxString language_code = wxString::FromUTF8(GetStudioLanguage()).BeforeFirst('_');
|
||||
|
||||
m_online_LastUrl = (boost::format("%1%%2%/studio/webview/search?keyword=%3%&from=bambustudio") % host % language_code.mb_str() % UrlEncode(KeyWord)).str();
|
||||
|
||||
|
@ -1699,8 +1685,7 @@ void WebViewPanel::SetMakerworldModelID(std::string ModelID)
|
|||
{
|
||||
auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
|
||||
|
||||
wxString language_code = wxGetApp().current_language_code().BeforeFirst('_');
|
||||
language_code = language_code.ToStdString();
|
||||
wxString language_code = wxString::FromUTF8(GetStudioLanguage()).BeforeFirst('_');
|
||||
|
||||
if (ModelID != "")
|
||||
m_online_LastUrl = (boost::format("%1%%2%/studio/webview?modelid=%3%&from=bambustudio") % host % language_code.mb_str() % ModelID).str();
|
||||
|
@ -1712,8 +1697,7 @@ void WebViewPanel::SetPrintHistoryTaskID(int TaskID)
|
|||
{
|
||||
auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
|
||||
|
||||
wxString language_code = wxGetApp().current_language_code().BeforeFirst('_');
|
||||
language_code = language_code.ToStdString();
|
||||
wxString language_code = wxString::FromUTF8(GetStudioLanguage()).BeforeFirst('_');
|
||||
|
||||
if (TaskID != 0)
|
||||
m_print_history_LastUrl = (boost::format("%1%%2%/studio/print-history/%3%?from=bambustudio") % host % language_code.mb_str() % TaskID).str();
|
||||
|
@ -1727,7 +1711,7 @@ void WebViewPanel::SwitchWebContent(std::string modelname, int refresh)
|
|||
|
||||
CheckMenuNewTag();
|
||||
|
||||
wxString strlang = wxGetApp().current_language_code_safe();
|
||||
wxString strlang = GetStudioLanguage();
|
||||
|
||||
if (modelname.compare("makerlab") == 0)
|
||||
{
|
||||
|
@ -1949,6 +1933,14 @@ void WebViewPanel::SetWebviewShow(wxString name, bool show)
|
|||
}
|
||||
}
|
||||
|
||||
std::string WebViewPanel::GetStudioLanguage()
|
||||
{
|
||||
std::string strLanguage=wxGetApp().app_config->get("language");
|
||||
if (strLanguage.empty()) strLanguage = "en";
|
||||
|
||||
return strLanguage;
|
||||
}
|
||||
|
||||
SourceViewDialog::SourceViewDialog(wxWindow* parent, wxString source) :
|
||||
wxDialog(parent, wxID_ANY, "Source Code",
|
||||
wxDefaultPosition, wxSize(700,500),
|
||||
|
|
|
@ -131,7 +131,6 @@ public:
|
|||
void get_user_mw_4u_config(std::function<void(std::string)> callback);
|
||||
void get_4u_staffpick(int seed, int limit, std::function<void(std::string)> callback);
|
||||
void OpenModelDetail(std::string id, NetworkAgent *agent);
|
||||
int get_model_mall_detail_url(std::string *url, std::string id);
|
||||
void UpdateMakerworldLoginStatus();
|
||||
void SetMakerworldPageLoginStatus(bool login, wxString ticket = "");
|
||||
|
||||
|
@ -149,6 +148,7 @@ public:
|
|||
|
||||
//Common UI
|
||||
void SetWebviewShow(wxString name, bool show);
|
||||
std::string GetStudioLanguage();
|
||||
|
||||
//PrintHistory
|
||||
std::string m_TaskInfo;
|
||||
|
|
Loading…
Reference in New Issue