From f9de995f9e6b8d64efde122563abee67148a1fb7 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 17 Mar 2023 09:28:13 +0100 Subject: [PATCH] Remove '_utf8' makro. (Initially, it was used because of using of boost::format for localized lines. But now It's better to use format and formal_wxstr functions) + Fixed missed marks for localization + Added missed filed to localization to the list.txt --- resources/localization/list.txt | 2 ++ src/libslic3r/AppConfig.cpp | 6 ---- src/libslic3r/I18N.hpp | 2 -- src/libslic3r/Zipper.cpp | 4 --- src/slic3r/GUI/AboutDialog.cpp | 33 +++++++++--------- src/slic3r/GUI/BackgroundSlicingProcess.cpp | 36 +++++++++---------- src/slic3r/GUI/BonjourDialog.cpp | 6 ++-- src/slic3r/GUI/ConfigSnapshotDialog.cpp | 4 +-- src/slic3r/GUI/ConfigWizard.cpp | 20 +++++------ src/slic3r/GUI/DoubleSlider.cpp | 2 +- src/slic3r/GUI/Field.cpp | 11 +++--- src/slic3r/GUI/GLCanvas3D.cpp | 38 ++++++++++----------- src/slic3r/GUI/GUI_App.cpp | 2 +- src/slic3r/GUI/GUI_Factories.cpp | 6 ++-- src/slic3r/GUI/GUI_ObjectSettings.cpp | 4 +-- src/slic3r/GUI/HintNotification.cpp | 8 ++--- src/slic3r/GUI/I18N.hpp | 1 - src/slic3r/GUI/Jobs/RotoptimizeJob.cpp | 10 ++++++ src/slic3r/GUI/Jobs/RotoptimizeJob.hpp | 10 ++---- src/slic3r/GUI/Jobs/SLAImportDialog.hpp | 2 +- src/slic3r/GUI/MainFrame.cpp | 4 +-- src/slic3r/GUI/NotificationManager.cpp | 4 +-- src/slic3r/GUI/OpenGLManager.cpp | 17 +++++---- src/slic3r/GUI/Plater.cpp | 22 ++++++------ src/slic3r/GUI/PresetHints.cpp | 36 +++++++++---------- src/slic3r/GUI/PrintHostDialogs.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 18 +++++----- src/slic3r/GUI/UpdateDialogs.cpp | 11 +++--- src/slic3r/GUI/wxExtensions.cpp | 5 ++- src/slic3r/Utils/AppUpdater.cpp | 22 ++++++------ src/slic3r/Utils/AstroBox.cpp | 10 +++--- src/slic3r/Utils/Duet.cpp | 4 +-- src/slic3r/Utils/FlashAir.cpp | 8 ++--- src/slic3r/Utils/MKS.cpp | 4 +-- src/slic3r/Utils/OctoPrint.cpp | 26 ++++++-------- src/slic3r/Utils/Repetier.cpp | 14 ++++---- 36 files changed, 195 insertions(+), 219 deletions(-) diff --git a/resources/localization/list.txt b/resources/localization/list.txt index b239c8d9a2..875e92721c 100644 --- a/resources/localization/list.txt +++ b/resources/localization/list.txt @@ -87,6 +87,7 @@ src/slic3r/GUI/UpdateDialogs.cpp src/slic3r/GUI/WipeTowerDialog.cpp src/slic3r/GUI/wxExtensions.cpp src/slic3r/Utils/AstroBox.cpp +src/slic3r/Utils/AppUpdater.cpp src/slic3r/Utils/Duet.cpp src/slic3r/Utils/FixModelByWin10.cpp src/slic3r/Utils/FlashAir.cpp @@ -101,6 +102,7 @@ src/libslic3r/ExtrusionEntity.cpp src/libslic3r/Flow.cpp src/libslic3r/Format/3mf.cpp src/libslic3r/Format/AMF.cpp +src/libslic3r/Format/SLAArchiveReader.cpp src/libslic3r/GCode/PostProcessor.cpp src/libslic3r/miniz_extension.cpp src/libslic3r/Preset.cpp diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index be16a2015e..f88b80c92a 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -340,12 +340,6 @@ std::string AppConfig::load(const std::string &path) // Error while parsing config file. We'll customize the error message and rethrow to be displayed. // ! But to avoid the use of _utf8 (related to use of wxWidgets) // we will rethrow this exception from the place of load() call, if returned value wouldn't be empty - /* - throw Slic3r::RuntimeError( - _utf8(L("Error parsing PrusaSlicer config file, it is probably corrupted. " - "Try to manually delete the file to recover from the error. Your user profiles will not be affected.")) + - "\n\n" + AppConfig::config_path() + "\n\n" + ex.what()); - */ return ex.what(); } } diff --git a/src/libslic3r/I18N.hpp b/src/libslic3r/I18N.hpp index 51d41a3ea1..ee39df2e1a 100644 --- a/src/libslic3r/I18N.hpp +++ b/src/libslic3r/I18N.hpp @@ -30,8 +30,6 @@ namespace I18N { namespace { const char* L(const char* s) { return s; } std::string _u8L(const char* s) { return Slic3r::I18N::translate(s); } - std::string _utf8(const char* s) { return Slic3r::I18N::translate(s); } - std::string _utf8(const std::string& s) { return Slic3r::I18N::translate(s); } } #endif diff --git a/src/libslic3r/Zipper.cpp b/src/libslic3r/Zipper.cpp index 29ca264ca1..53c39c3a75 100644 --- a/src/libslic3r/Zipper.cpp +++ b/src/libslic3r/Zipper.cpp @@ -6,10 +6,6 @@ #include #include "I18N.hpp" -//! macro used to mark string used at localization, -//! return same string -#define _u8L(s) Slic3r::I18N::translate(s) - #if defined(_MSC_VER) && _MSC_VER <= 1800 || __cplusplus < 201103L #define SLIC3R_NORETURN #elif __cplusplus >= 201103L diff --git a/src/slic3r/GUI/AboutDialog.cpp b/src/slic3r/GUI/AboutDialog.cpp index 823a315b73..132159ff55 100644 --- a/src/slic3r/GUI/AboutDialog.cpp +++ b/src/slic3r/GUI/AboutDialog.cpp @@ -41,9 +41,9 @@ void AboutDialogLogo::onRepaint(wxEvent &event) // CopyrightsDialog // ----------------------------------------- CopyrightsDialog::CopyrightsDialog() - : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, from_u8((boost::format("%1% - %2%") - % (wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME) - % _utf8(L("Portions copyright"))).str()), + : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, format_wxstr("%1% - %2%" + , wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME + , _L("Portions copyright")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { this->SetFont(wxGetApp().normal_font()); @@ -211,7 +211,7 @@ void CopyrightsDialog::onCloseDialog(wxEvent &) } AboutDialog::AboutDialog() - : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, from_u8((boost::format(_utf8(L("About %s"))) % (wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME)).str()), wxDefaultPosition, + : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, format_wxstr(_L("About %s"), wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME), wxDefaultPosition, wxDefaultSize, /*wxCAPTION*/wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { SetFont(wxGetApp().normal_font()); @@ -267,14 +267,13 @@ AboutDialog::AboutDialog() int size[] = {fs,fs,fs,fs,fs,fs,fs}; m_html->SetFonts(font.GetFaceName(), font.GetFaceName(), size); m_html->SetBorders(2); - const std::string copyright_str = _utf8(L("Copyright")); + const wxString copyright_str = _L("Copyright"); // TRN "Slic3r _is licensed under the_ License" - const std::string is_lecensed_str = _utf8(L("is licensed under the")); - const std::string license_str = _utf8(L("GNU Affero General Public License, version 3")); - const std::string based_on_str = _utf8(L("PrusaSlicer is based on Slic3r by Alessandro Ranellucci and the RepRap community.")); - const std::string contributors_str = _utf8(L("Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Joseph Lenox, Y. Sapir, Mike Sheldrake, Vojtech Bubnik and numerous others.")); - const auto text = from_u8( - (boost::format( + const wxString is_lecensed_str = _L("is licensed under the"); + const wxString license_str = _L("GNU Affero General Public License, version 3"); + const wxString based_on_str = _L("PrusaSlicer is based on Slic3r by Alessandro Ranellucci and the RepRap community."); + const wxString contributors_str = _L("Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Joseph Lenox, Y. Sapir, Mike Sheldrake, Vojtech Bubnik and numerous others."); + const auto text = format_wxstr( "" "" "" @@ -288,12 +287,12 @@ AboutDialog::AboutDialog() "%9%" "" "" - "") % bgr_clr_str % text_clr_str % text_clr_str - % copyright_str % copyright_str - % is_lecensed_str - % license_str - % based_on_str - % contributors_str).str()); + "", bgr_clr_str, text_clr_str, text_clr_str + , copyright_str, copyright_str + , is_lecensed_str + , license_str + , based_on_str + , contributors_str); m_html->SetPage(text); vsizer->Add(m_html, 1, wxEXPAND | wxBOTTOM, 10); m_html->Bind(wxEVT_HTML_LINK_CLICKED, &AboutDialog::onLinkClicked, this); diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index 2348255081..9ee6946c61 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -76,10 +76,10 @@ std::pair SlicingProcessCompletedEvent::format_error_message( try { this->rethrow_exception(); } catch (const std::bad_alloc &ex) { - wxString errmsg = GUI::from_u8((boost::format(_utf8(L("%s has encountered an error. It was likely caused by running out of memory. " + error = GUI::format(_L("%s has encountered an error. It was likely caused by running out of memory. " "If you are sure you have enough RAM on your system, this may also be a bug and we would " - "be glad if you reported it."))) % SLIC3R_APP_NAME).str()); - error = std::string(errmsg.ToUTF8()) + "\n\n" + std::string(ex.what()); + "be glad if you reported it."), SLIC3R_APP_NAME); + error += "\n\n" + std::string(ex.what()); } catch (const HardCrash &ex) { error = GUI::format(_L("PrusaSlicer has encountered a fatal error: \"%1%\""), ex.what()) + "\n\n" + _u8L("Please save your project and restart PrusaSlicer. " @@ -159,7 +159,7 @@ void BackgroundSlicingProcess::process_fff() wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, new wxCommandEvent(m_event_export_began_id)); prepare_upload(); } else { - m_print->set_status(100, _utf8(L("Slicing complete"))); + m_print->set_status(100, _u8L("Slicing complete")); } this->set_step_done(bspsGCodeFinalize); } @@ -180,12 +180,12 @@ void BackgroundSlicingProcess::process_sla() m_sla_print->export_print(export_path, thumbnails); - m_print->set_status(100, (boost::format(_utf8(L("Masked SLA file exported to %1%"))) % export_path).str()); + m_print->set_status(100, GUI::format(_L("Masked SLA file exported to %1%"), export_path)); } else if (! m_upload_job.empty()) { wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, new wxCommandEvent(m_event_export_began_id)); prepare_upload(); } else { - m_print->set_status(100, _utf8(L("Slicing complete"))); + m_print->set_status(100, _u8L("Slicing complete")); } this->set_step_done(bspsGCodeFinalize); } @@ -649,7 +649,7 @@ bool BackgroundSlicingProcess::invalidate_all_steps() // Copy the final G-code to target location (possibly a SD card, if it is a removable media, then verify that the file was written without an error). void BackgroundSlicingProcess::finalize_gcode() { - m_print->set_status(95, _utf8(L("Running post-processing scripts"))); + m_print->set_status(95, _u8L("Running post-processing scripts")); // Perform the final post-processing of the export path by applying the print statistics over the file name. std::string export_path = m_fff_print->print_statistics().finalize_output_path(m_export_path); @@ -680,32 +680,32 @@ void BackgroundSlicingProcess::finalize_gcode() catch (...) { remove_post_processed_temp_file(); - throw Slic3r::ExportError(_utf8(L("Unknown error occured during exporting G-code."))); + throw Slic3r::ExportError(_u8L("Unknown error occured during exporting G-code.")); } switch (copy_ret_val) { case CopyFileResult::SUCCESS: break; // no error case CopyFileResult::FAIL_COPY_FILE: - throw Slic3r::ExportError((boost::format(_utf8(L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?\nError message: %1%"))) % error_message).str()); + throw Slic3r::ExportError(GUI::format(_L("Copying of the temporary G-code to the output G-code failed. Maybe the SD card is write locked?\nError message: %1%"), error_message)); break; case CopyFileResult::FAIL_FILES_DIFFERENT: - throw Slic3r::ExportError((boost::format(_utf8(L("Copying of the temporary G-code to the output G-code failed. There might be problem with target device, please try exporting again or using different device. The corrupted output G-code is at %1%.tmp."))) % export_path).str()); + throw Slic3r::ExportError(GUI::format(_L("Copying of the temporary G-code to the output G-code failed. There might be problem with target device, please try exporting again or using different device. The corrupted output G-code is at %1%.tmp."), export_path)); break; case CopyFileResult::FAIL_RENAMING: - throw Slic3r::ExportError((boost::format(_utf8(L("Renaming of the G-code after copying to the selected destination folder has failed. Current path is %1%.tmp. Please try exporting again."))) % export_path).str()); + throw Slic3r::ExportError(GUI::format(_L("Renaming of the G-code after copying to the selected destination folder has failed. Current path is %1%.tmp. Please try exporting again."), export_path)); break; case CopyFileResult::FAIL_CHECK_ORIGIN_NOT_OPENED: - throw Slic3r::ExportError((boost::format(_utf8(L("Copying of the temporary G-code has finished but the original code at %1% couldn't be opened during copy check. The output G-code is at %2%.tmp."))) % output_path % export_path).str()); + throw Slic3r::ExportError(GUI::format(_L("Copying of the temporary G-code has finished but the original code at %1% couldn't be opened during copy check. The output G-code is at %2%.tmp."), output_path, export_path)); break; case CopyFileResult::FAIL_CHECK_TARGET_NOT_OPENED: - throw Slic3r::ExportError((boost::format(_utf8(L("Copying of the temporary G-code has finished but the exported code couldn't be opened during copy check. The output G-code is at %1%.tmp."))) % export_path).str()); + throw Slic3r::ExportError(GUI::format(_L("Copying of the temporary G-code has finished but the exported code couldn't be opened during copy check. The output G-code is at %1%.tmp."), export_path)); break; default: - throw Slic3r::ExportError(_utf8(L("Unknown error occured during exporting G-code."))); + throw Slic3r::ExportError(_u8L("Unknown error occured during exporting G-code.")); BOOST_LOG_TRIVIAL(error) << "Unexpected fail code(" << (int)copy_ret_val << ") durring copy_file() to " << export_path << "."; break; } - m_print->set_status(100, (boost::format(_utf8(L("G-code file exported to %1%"))) % export_path).str()); + m_print->set_status(100, GUI::format(_L("G-code file exported to %1%"), export_path)); } // A print host upload job has been scheduled, enqueue it to the printhost job queue @@ -716,10 +716,10 @@ void BackgroundSlicingProcess::prepare_upload() / boost::filesystem::unique_path("." SLIC3R_APP_KEY ".upload.%%%%-%%%%-%%%%-%%%%"); if (m_print == m_fff_print) { - m_print->set_status(95, _utf8(L("Running post-processing scripts"))); + m_print->set_status(95, _u8L("Running post-processing scripts")); std::string error_message; if (copy_file(m_temp_output_path, source_path.string(), error_message) != SUCCESS) - throw Slic3r::RuntimeError(_utf8(L("Copying of the temporary G-code to the output G-code failed"))); + throw Slic3r::RuntimeError(_u8L("Copying of the temporary G-code to the output G-code failed")); m_upload_job.upload_data.upload_path = m_fff_print->print_statistics().finalize_output_path(m_upload_job.upload_data.upload_path.string()); // Make a copy of the source path, as run_post_process_scripts() is allowed to change it when making a copy of the source file // (not here, but when the final target is a file). @@ -735,7 +735,7 @@ void BackgroundSlicingProcess::prepare_upload() m_sla_print->export_print(source_path.string(),thumbnails, m_upload_job.upload_data.upload_path.filename().string()); } - m_print->set_status(100, (boost::format(_utf8(L("Scheduling upload to `%1%`. See Window -> Print Host Upload Queue"))) % m_upload_job.printhost->get_host()).str()); + m_print->set_status(100, GUI::format(_L("Scheduling upload to `%1%`. See Window -> Print Host Upload Queue"), m_upload_job.printhost->get_host())); m_upload_job.upload_data.source_path = std::move(source_path); diff --git a/src/slic3r/GUI/BonjourDialog.cpp b/src/slic3r/GUI/BonjourDialog.cpp index 9298aa615b..060643c1ff 100644 --- a/src/slic3r/GUI/BonjourDialog.cpp +++ b/src/slic3r/GUI/BonjourDialog.cpp @@ -224,14 +224,14 @@ void BonjourDialog::on_timer(wxTimerEvent &) // explicitly (wxTimerEvent should not be created by user code). void BonjourDialog::on_timer_process() { - const auto search_str = _utf8(L("Searching for devices")); + const auto search_str = _L("Searching for devices"); if (timer_state > 0) { const std::string dots(timer_state, '.'); - label->SetLabel(GUI::from_u8((boost::format("%1% %2%") % search_str % dots).str())); + label->SetLabel(search_str + dots); timer_state = (timer_state) % 3 + 1; } else { - label->SetLabel(GUI::from_u8((boost::format("%1%: %2%") % search_str % (_utf8(L("Finished"))+".")).str())); + label->SetLabel(search_str + ": " + _L("Finished") + "."); timer->Stop(); } } diff --git a/src/slic3r/GUI/ConfigSnapshotDialog.cpp b/src/slic3r/GUI/ConfigSnapshotDialog.cpp index e2bea55d13..c1817a3baf 100644 --- a/src/slic3r/GUI/ConfigSnapshotDialog.cpp +++ b/src/slic3r/GUI/ConfigSnapshotDialog.cpp @@ -89,10 +89,10 @@ static wxString generate_html_row(const Config::Snapshot &snapshot, bool row_eve } if (! compatible) { - text += "

" + from_u8((boost::format(_utf8(L("Incompatible with this %s"))) % SLIC3R_APP_NAME).str()) + "

"; + text += "

" + format_wxstr(_L("Incompatible with this %s"), SLIC3R_APP_NAME) + "

"; } else if (! snapshot_active) - text += "

" + _(L("Activate")) + "

"; + text += "

" + _L("Activate") + "

"; text += ""; text += ""; return text; diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 65d08f195b..aa2de94afc 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -289,7 +289,7 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt const auto &variant = model.variants[i]; const auto label = model.technology == ptFFF - ? from_u8((boost::format("%1% %2% %3%") % variant.name % _utf8(L("mm")) % _utf8(L("nozzle"))).str()) + ? format_wxstr("%1% %2% %3%", variant.name, _L("mm"), _L("nozzle")) : from_u8(model.name); if (i == 1) { @@ -509,17 +509,17 @@ void ConfigWizardPage::append_spacer(int space) // Wizard pages PageWelcome::PageWelcome(ConfigWizard *parent) - : ConfigWizardPage(parent, from_u8((boost::format( + : ConfigWizardPage(parent, format_wxstr( #ifdef __APPLE__ - _utf8(L("Welcome to the %s Configuration Assistant")) + _L("Welcome to the %s Configuration Assistant") #else - _utf8(L("Welcome to the %s Configuration Wizard")) + _L("Welcome to the %s Configuration Wizard") #endif - ) % SLIC3R_APP_NAME).str()), _L("Welcome")) - , welcome_text(append_text(from_u8((boost::format( - _utf8(L("Hello, welcome to %s! This %s helps you with the initial configuration; just a few settings and you will be ready to print."))) - % SLIC3R_APP_NAME - % _utf8(ConfigWizard::name())).str()) + , SLIC3R_APP_NAME), _L("Welcome")) + , welcome_text(append_text(format_wxstr( + _L("Hello, welcome to %s! This %s helps you with the initial configuration; just a few settings and you will be ready to print.") + , SLIC3R_APP_NAME + , _(ConfigWizard::name())) )) , cbox_reset(append( new wxCheckBox(this, wxID_ANY, _L("Remove user profiles (a snapshot will be taken beforehand)")) @@ -577,7 +577,7 @@ PagePrinters::PagePrinters(ConfigWizard *parent, continue; } - const auto picker_title = family.empty() ? wxString() : from_u8((boost::format(_utf8(L("%s Family"))) % family).str()); + const auto picker_title = family.empty() ? wxString() : format_wxstr(_L("%s Family"), family); auto *picker = new PrinterPicker(this, vendor, picker_title, MAX_COLS, *appconfig, filter); picker->Bind(EVT_PRINTER_PICK, [this, appconfig](const PrinterPickerEvent &evt) { diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index 99b8d73d55..a0816c22f8 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -106,7 +106,7 @@ Control::Control( wxWindow *parent, m_cog_icon_dim = m_bmp_cog.GetWidth(); m_selection = ssUndef; - m_ticks.set_pause_print_msg(_utf8(L("Place bearings in slots and resume printing"))); + m_ticks.set_pause_print_msg(_u8L("Place bearings in slots and resume printing")); m_ticks.set_extruder_colors(&m_extruder_colors); // slider events diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index c6ffa46ec4..74ad028d36 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -226,7 +226,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true } wxString label = m_opt.full_label.empty() ? _(m_opt.label) : _(m_opt.full_label); - show_error(m_parent, from_u8((boost::format(_utf8(L("%s doesn't support percentage"))) % label).str())); + show_error(m_parent, format_wxstr(_L("%s doesn't support percentage"), label)); set_value(double_to_string(m_opt.min), true); m_value = double(m_opt.min); break; @@ -299,7 +299,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true // Workaroud to avoid of using of the % for first layer height // see https://github.com/prusa3d/PrusaSlicer/issues/7418 wxString label = m_opt.full_label.empty() ? _(m_opt.label) : _(m_opt.full_label); - show_error(m_parent, from_u8((boost::format(_utf8(L("%s doesn't support percentage"))) % label).str())); + show_error(m_parent, format_wxstr(_L("%s doesn't support percentage"), label)); const wxString stVal = double_to_string(0.01, 2); set_value(stVal, true); m_value = into_u8(stVal);; @@ -341,9 +341,10 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true const std::string sidetext = m_opt.sidetext.rfind("mm/s") != std::string::npos ? "mm/s" : "mm"; const wxString stVal = double_to_string(val, 2); - const wxString msg_text = from_u8((boost::format(_utf8(L("Do you mean %s%% instead of %s %s?\n" - "Select YES if you want to change this value to %s%%, \n" - "or NO if you are sure that %s %s is a correct value."))) % stVal % stVal % sidetext % stVal % stVal % sidetext).str()); + // TRN %1% = Value, %2% = units + const wxString msg_text = format_wxstr(_L("Do you mean %1%%% instead of %1% %2%?\n" + "Select YES if you want to change this value to %1%%%, \n" + "or NO if you are sure that %1% %2% is a correct value."), stVal, sidetext); WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxYES | wxNO); if ((!infill_anchors || val > 100) && dialog.ShowModal() == wxID_YES) { set_value(from_u8((boost::format("%s%%") % stVal).str()), false/*true*/); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 6924667e6b..dcc85dc65f 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -728,7 +728,7 @@ void GLCanvas3D::Labels::render(const std::vector& sorted_ return owner.model_instance_id == id; }); if (it != owners.end()) - it->print_order = std::string((_(L("Seq."))).ToUTF8()) + "#: " + std::to_string(i + 1); + it->print_order = _u8L("Seq.") + "#: " + std::to_string(i + 1); } } @@ -4711,7 +4711,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "add"; item.icon_filename = "add.svg"; - item.tooltip = _utf8(L("Add...")) + " [" + GUI::shortkey_ctrl_prefix() + "I]"; + item.tooltip = _u8L("Add...") + " [" + GUI::shortkey_ctrl_prefix() + "I]"; item.sprite_id = 0; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ADD)); }; if (!m_main_toolbar.add_item(item)) @@ -4719,7 +4719,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "delete"; item.icon_filename = "remove.svg"; - item.tooltip = _utf8(L("Delete")) + " [Del]"; + item.tooltip = _u8L("Delete") + " [Del]"; item.sprite_id = 1; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE)); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete(); }; @@ -4728,7 +4728,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "deleteall"; item.icon_filename = "delete_all.svg"; - item.tooltip = _utf8(L("Delete all")) + " [" + GUI::shortkey_ctrl_prefix() + "Del]"; + item.tooltip = _u8L("Delete all") + " [" + GUI::shortkey_ctrl_prefix() + "Del]"; item.sprite_id = 2; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete_all(); }; @@ -4737,7 +4737,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "arrange"; item.icon_filename = "arrange.svg"; - item.tooltip = _utf8(L("Arrange")) + " [A]\n" + _utf8(L("Arrange selection")) + " [Shift+A]\n" + _utf8(L("Click right mouse button to show arrangement options")); + item.tooltip = _u8L("Arrange") + " [A]\n" + _u8L("Arrange selection") + " [Shift+A]\n" + _u8L("Click right mouse button to show arrangement options"); item.sprite_id = 3; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ARRANGE)); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_arrange(); }; @@ -4757,7 +4757,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "copy"; item.icon_filename = "copy.svg"; - item.tooltip = _utf8(L("Copy")) + " [" + GUI::shortkey_ctrl_prefix() + "C]"; + item.tooltip = _u8L("Copy") + " [" + GUI::shortkey_ctrl_prefix() + "C]"; item.sprite_id = 4; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_COPY)); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_copy_to_clipboard(); }; @@ -4766,7 +4766,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "paste"; item.icon_filename = "paste.svg"; - item.tooltip = _utf8(L("Paste")) + " [" + GUI::shortkey_ctrl_prefix() + "V]"; + item.tooltip = _u8L("Paste") + " [" + GUI::shortkey_ctrl_prefix() + "V]"; item.sprite_id = 5; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_PASTE)); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_paste_from_clipboard(); }; @@ -4778,7 +4778,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "more"; item.icon_filename = "instance_add.svg"; - item.tooltip = _utf8(L("Add instance")) + " [+]"; + item.tooltip = _u8L("Add instance") + " [+]"; item.sprite_id = 6; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_MORE)); }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; @@ -4789,7 +4789,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "fewer"; item.icon_filename = "instance_remove.svg"; - item.tooltip = _utf8(L("Remove instance")) + " [-]"; + item.tooltip = _u8L("Remove instance") + " [-]"; item.sprite_id = 7; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_FEWER)); }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; @@ -4802,7 +4802,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "splitobjects"; item.icon_filename = "split_objects.svg"; - item.tooltip = _utf8(L("Split to objects")); + item.tooltip = _u8L("Split to objects"); item.sprite_id = 8; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_OBJECTS)); }; item.visibility_callback = GLToolbarItem::Default_Visibility_Callback; @@ -4812,7 +4812,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "splitvolumes"; item.icon_filename = "split_parts.svg"; - item.tooltip = _utf8(L("Split to parts")); + item.tooltip = _u8L("Split to parts"); item.sprite_id = 9; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_VOLUMES)); }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; @@ -4826,8 +4826,8 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "settings"; item.icon_filename = "settings.svg"; item.tooltip = _u8L("Switch to Settings") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "2] - " + _u8L("Print Settings Tab") + - "\n" + "[" + GUI::shortkey_ctrl_prefix() + "3] - " + (current_printer_technology() == ptFFF ? _u8L("Filament Settings Tab") : _u8L("Material Settings Tab")) + - "\n" + "[" + GUI::shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab") ; + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "3] - " + (current_printer_technology() == ptFFF ? _u8L("Filament Settings Tab") : _u8L("Material Settings Tab") + + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab")) ; item.sprite_id = 10; item.enabling_callback = GLToolbarItem::Default_Enabling_Callback; item.visibility_callback = []() { return wxGetApp().app_config->get_bool("new_settings_layout_mode") || @@ -4843,7 +4843,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "search"; item.icon_filename = "search_.svg"; - item.tooltip = _utf8(L("Search")) + " [" + GUI::shortkey_ctrl_prefix() + "F]"; + item.tooltip = _u8L("Search") + " [" + GUI::shortkey_ctrl_prefix() + "F]"; item.sprite_id = 11; item.left.toggable = true; item.left.render_callback = [this](float left, float right, float, float) { @@ -4865,7 +4865,7 @@ bool GLCanvas3D::_init_main_toolbar() item.name = "layersediting"; item.icon_filename = "layers_white.svg"; - item.tooltip = _utf8(L("Variable layer height")); + item.tooltip = _u8L("Variable layer height"); item.sprite_id = 12; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); }; item.visibility_callback = [this]()->bool { @@ -4918,7 +4918,7 @@ bool GLCanvas3D::_init_undoredo_toolbar() item.name = "undo"; item.icon_filename = "undo_toolbar.svg"; - item.tooltip = _utf8(L("Undo")) + " [" + GUI::shortkey_ctrl_prefix() + "Z]\n" + _utf8(L("Click right mouse button to open/close History")); + item.tooltip = _u8L("Undo") + " [" + GUI::shortkey_ctrl_prefix() + "Z]\n" + _u8L("Click right mouse button to open/close History"); item.sprite_id = 0; item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_UNDO)); }; item.right.toggable = true; @@ -4940,7 +4940,7 @@ bool GLCanvas3D::_init_undoredo_toolbar() if (can_undo) { std::string action; wxGetApp().plater()->undo_redo_topmost_string_getter(true, action); - new_additional_tooltip = (boost::format(_utf8(L("Next Undo action: %1%"))) % action).str(); + new_additional_tooltip = format(_L("Next Undo action: %1%"), action); } if (new_additional_tooltip != curr_additional_tooltip) { @@ -4955,7 +4955,7 @@ bool GLCanvas3D::_init_undoredo_toolbar() item.name = "redo"; item.icon_filename = "redo_toolbar.svg"; - item.tooltip = _utf8(L("Redo")) + " [" + GUI::shortkey_ctrl_prefix() + "Y]\n" + _utf8(L("Click right mouse button to open/close History")); + item.tooltip = _u8L("Redo") + " [" + GUI::shortkey_ctrl_prefix() + "Y]\n" + _u8L("Click right mouse button to open/close History"); item.sprite_id = 1; item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_REDO)); }; item.right.action_callback = [this]() { m_imgui_undo_redo_hovered_pos = -1; }; @@ -4976,7 +4976,7 @@ bool GLCanvas3D::_init_undoredo_toolbar() if (can_redo) { std::string action; wxGetApp().plater()->undo_redo_topmost_string_getter(false, action); - new_additional_tooltip = (boost::format(_utf8(L("Next Redo action: %1%"))) % action).str(); + new_additional_tooltip = format(_L("Next Redo action: %1%"), action); } if (new_additional_tooltip != curr_additional_tooltip) { diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 4be6de6e1e..fe1fd20124 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3440,7 +3440,7 @@ void GUI_App::app_updater(bool from_user) } app_data.target_path =dwnld_dlg.get_download_path(); // start download - this->plater_->get_notification_manager()->push_download_progress_notification(GUI::format(_utf8("Downloading %1%"), app_data.target_path.filename().string()), std::bind(&AppUpdater::cancel_callback, this->m_app_updater.get())); + this->plater_->get_notification_manager()->push_download_progress_notification(GUI::format(_L("Downloading %1%"), app_data.target_path.filename().string()), std::bind(&AppUpdater::cancel_callback, this->m_app_updater.get())); app_data.start_after = dwnld_dlg.run_after_download(); m_app_updater->set_app_data(std::move(app_data)); m_app_updater->sync_download(); diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index df8ace79a3..4887d3dcfc 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -411,7 +411,7 @@ static void create_freq_settings_popupmenu(wxMenu* menu, const bool is_object_se if (is_improper_category(category.first, extruders_cnt)) continue; - append_menu_item(menu, wxID_ANY, from_u8((boost::format(_utf8(L("Quick Add Settings (%s)"))) % _(it.first)).str()), "", + append_menu_item(menu, wxID_ANY, format_wxstr(_L("Quick Add Settings (%s)"), _(it.first)), "", [menu, item, is_object_settings, bundle](wxCommandEvent& event) { wxString category_name = menu->GetLabel(event.GetId()); std::vector options; @@ -622,13 +622,13 @@ wxMenuItem* MenuFactory::append_menu_item_settings(wxMenu* menu_) #if 0 for (auto& it : m_freq_settings_fff) { - settings_id = menu->FindItem(from_u8((boost::format(_utf8(L("Quick Add Settings (%s)"))) % _(it.first)).str())); + settings_id = menu->FindItem(format_wxstr(_L("Quick Add Settings (%s)"), _(it.first))); if (settings_id != wxNOT_FOUND) menu->Destroy(settings_id); } for (auto& it : m_freq_settings_sla) { - settings_id = menu->FindItem(from_u8((boost::format(_utf8(L("Quick Add Settings (%s)"))) % _(it.first)).str())); + settings_id = menu->FindItem(format_wxstr(_L("Quick Add Settings (%s)"), _(it.first))); if (settings_id != wxNOT_FOUND) menu->Destroy(settings_id); } diff --git a/src/slic3r/GUI/GUI_ObjectSettings.cpp b/src/slic3r/GUI/GUI_ObjectSettings.cpp index 97eb5f10d9..41cad87921 100644 --- a/src/slic3r/GUI/GUI_ObjectSettings.cpp +++ b/src/slic3r/GUI/GUI_ObjectSettings.cpp @@ -102,7 +102,7 @@ bool ObjectSettings::update_settings_list() btn->SetBitmapCurrent(m_bmp_delete_focus.bmp()); btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) { - wxGetApp().plater()->take_snapshot(from_u8((boost::format(_utf8(L("Delete Option %s"))) % opt_key).str())); + wxGetApp().plater()->take_snapshot(format_wxstr(_L("Delete Option %s"), opt_key)); config->erase(opt_key); wxGetApp().obj_list()->changed_object(); wxTheApp->CallAfter([this]() { @@ -151,7 +151,7 @@ bool ObjectSettings::update_settings_list() for (auto& opt : cat.second) optgroup->get_field(opt)->m_on_change = [optgroup](const std::string& opt_id, const boost::any& value) { // first of all take a snapshot and then change value in configuration - wxGetApp().plater()->take_snapshot(from_u8((boost::format(_utf8(L("Change Option %s"))) % opt_id).str())); + wxGetApp().plater()->take_snapshot(format_wxstr(_L("Change Option %s"), opt_id)); optgroup->on_change_OG(opt_id, value); }; diff --git a/src/slic3r/GUI/HintNotification.cpp b/src/slic3r/GUI/HintNotification.cpp index 1f3d224919..95583a3cdd 100644 --- a/src/slic3r/GUI/HintNotification.cpp +++ b/src/slic3r/GUI/HintNotification.cpp @@ -344,7 +344,7 @@ void HintDatabase::load_hints_from_file(const boost::filesystem::path& path) bool was_displayed = is_used(id_string); //unescape text1 unescape_string_cstyle(dict["text"], fulltext); - fulltext = _utf8(fulltext); + fulltext = into_u8(_(fulltext)); #ifdef __APPLE__ boost::replace_all(fulltext, "Ctrl+", "⌘"); #endif //__APPLE__ @@ -370,19 +370,19 @@ void HintDatabase::load_hints_from_file(const boost::filesystem::path& path) fulltext.erase(hypertext_start, HYPERTEXT_MARKER_START.size()); if (fulltext.find(HYPERTEXT_MARKER_START) != std::string::npos) { // This must not happen - only 1 hypertext allowed - BOOST_LOG_TRIVIAL(error) << "Hint notification with multiple hypertexts: " << _utf8(dict["text"]); + BOOST_LOG_TRIVIAL(error) << "Hint notification with multiple hypertexts: " << dict["text"]; continue; } size_t hypertext_end = fulltext.find(HYPERTEXT_MARKER_END); if (hypertext_end == std::string::npos) { // hypertext was not correctly ended - BOOST_LOG_TRIVIAL(error) << "Hint notification without hypertext end marker: " << _utf8(dict["text"]); + BOOST_LOG_TRIVIAL(error) << "Hint notification without hypertext end marker: " << dict["text"]; continue; } fulltext.erase(hypertext_end, HYPERTEXT_MARKER_END.size()); if (fulltext.find(HYPERTEXT_MARKER_END) != std::string::npos) { // This must not happen - only 1 hypertext end allowed - BOOST_LOG_TRIVIAL(error) << "Hint notification with multiple hypertext end markers: " << _utf8(dict["text"]); + BOOST_LOG_TRIVIAL(error) << "Hint notification with multiple hypertext end markers: " << dict["text"]; continue; } diff --git a/src/slic3r/GUI/I18N.hpp b/src/slic3r/GUI/I18N.hpp index 7bad6880e9..8616628eaf 100644 --- a/src/slic3r/GUI/I18N.hpp +++ b/src/slic3r/GUI/I18N.hpp @@ -1,7 +1,6 @@ #ifndef _ #define _(s) Slic3r::GUI::I18N::translate((s)) #define _L(s) Slic3r::GUI::I18N::translate((s)) -#define _utf8(s) Slic3r::GUI::I18N::translate_utf8((s)) #define _u8L(s) Slic3r::GUI::I18N::translate_utf8((s)) #endif /* _ */ diff --git a/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp b/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp index 0980326d31..d33bee1a8d 100644 --- a/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp +++ b/src/slic3r/GUI/Jobs/RotoptimizeJob.cpp @@ -124,4 +124,14 @@ void RotoptimizeJob::finalize(bool canceled, std::exception_ptr &eptr) m_plater->update(); } +std::string RotoptimizeJob::get_method_name(size_t i) +{ + return into_u8(_(Methods[i].name)); +} + +std::string RotoptimizeJob::get_method_description(size_t i) +{ + return into_u8(_(Methods[i].descr)); +} + }} diff --git a/src/slic3r/GUI/Jobs/RotoptimizeJob.hpp b/src/slic3r/GUI/Jobs/RotoptimizeJob.hpp index 71a28deb7c..02aafb551e 100644 --- a/src/slic3r/GUI/Jobs/RotoptimizeJob.hpp +++ b/src/slic3r/GUI/Jobs/RotoptimizeJob.hpp @@ -58,15 +58,9 @@ public: static constexpr size_t get_methods_count() { return std::size(Methods); } - static std::string get_method_name(size_t i) - { - return _utf8(Methods[i].name); - } + static std::string get_method_name(size_t i); - static std::string get_method_description(size_t i) - { - return _utf8(Methods[i].descr); - } + static std::string get_method_description(size_t i); }; }} // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/Jobs/SLAImportDialog.hpp b/src/slic3r/GUI/Jobs/SLAImportDialog.hpp index 5477e51e7f..fed84600c2 100644 --- a/src/slic3r/GUI/Jobs/SLAImportDialog.hpp +++ b/src/slic3r/GUI/Jobs/SLAImportDialog.hpp @@ -30,7 +30,7 @@ std::string get_readers_wildcard() std::string ret; for (const char *archtype : SLAArchiveReader::registered_archives()) { - ret += _utf8(SLAArchiveReader::get_description(archtype)); + ret += into_u8(_(SLAArchiveReader::get_description(archtype))); ret += " ("; auto extensions = SLAArchiveReader::get_extensions(archtype); for (const char * ext : extensions) { diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index eccd96e201..071260ac2d 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -1755,7 +1755,7 @@ void MainFrame::quick_slice(const int qs) } else if (qs & qsSaveAs) { // The following line may die if the output_filename_format template substitution fails. - wxFileDialog dlg(this, from_u8((boost::format(_utf8(L("Save %s file as:"))) % ((qs & qsExportSVG) ? _L("SVG") : _L("G-code"))).str()), + wxFileDialog dlg(this, format_wxstr(_L("Save %s file as:"), ((qs & qsExportSVG) ? _L("SVG") : _L("G-code"))), wxGetApp().app_config->get_last_output_dir(get_dir_name(output_file)), get_base_name(input_file), qs & qsExportSVG ? file_wildcards(FT_SVG) : file_wildcards(FT_GCODE), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); @@ -1778,7 +1778,7 @@ void MainFrame::quick_slice(const int qs) // show processbar dialog m_progress_dialog = new wxProgressDialog(_L("Slicing") + dots, // TRN "Processing input_file_basename" - from_u8((boost::format(_utf8(L("Processing %s"))) % (input_file_basename + dots)).str()), + format_wxstr(_L("Processing %s"), (input_file_basename + dots)), 100, nullptr, wxPD_AUTO_HIDE); m_progress_dialog->Pulse(); { diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index ab465a577e..c96ed4dbcc 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -866,7 +866,7 @@ bool NotificationManager::ExportFinishedNotification::on_text_click() } void NotificationManager::ExportFinishedNotification::on_eject_click() { - NotificationData data{ get_data().type, get_data().level , 0, _utf8("Ejecting.") }; + NotificationData data{ get_data().type, get_data().level , 0, _u8L("Ejecting.") }; m_eject_pending = true; m_multiline = false; update(data); @@ -2447,7 +2447,7 @@ void NotificationManager::push_download_URL_progress_notification(size_t id, con } } // push new one - NotificationData data{ NotificationType::URLDownload, NotificationLevel::ProgressBarNotificationLevel, 5, _utf8("Download:") + " " + text }; + NotificationData data{ NotificationType::URLDownload, NotificationLevel::ProgressBarNotificationLevel, 5, _u8L("Download:") + " " + text }; push_notification_data(std::make_unique(data, m_id_provider, m_evt_handler, id, user_action_callback), 0); } diff --git a/src/slic3r/GUI/OpenGLManager.cpp b/src/slic3r/GUI/OpenGLManager.cpp index ecf0c57909..6960d0a756 100644 --- a/src/slic3r/GUI/OpenGLManager.cpp +++ b/src/slic3r/GUI/OpenGLManager.cpp @@ -371,16 +371,16 @@ bool OpenGLManager::init_gl() if (!valid_version) { // Complain about the OpenGL version. - wxString message = from_u8((boost::format( + wxString message = format_wxstr( #if ENABLE_OPENGL_ES - _utf8(L("PrusaSlicer requires OpenGL ES 2.0 capable graphics driver to run correctly, \n" - "while OpenGL version %s, render %s, vendor %s was detected."))) % s_gl_info.get_version_string() % s_gl_info.get_renderer() % s_gl_info.get_vendor()).str()); + _L("PrusaSlicer requires OpenGL ES 2.0 capable graphics driver to run correctly, \n" + "while OpenGL version %s, render %s, vendor %s was detected."), s_gl_info.get_version_string(), s_gl_info.get_renderer(), s_gl_info.get_vendor()); #elif ENABLE_GL_CORE_PROFILE - _utf8(L("PrusaSlicer requires OpenGL %s capable graphics driver to run correctly, \n" - "while OpenGL version %s, render %s, vendor %s was detected."))) % (s_gl_info.is_core_profile() ? "3.3" : "2.0") % s_gl_info.get_version_string() % s_gl_info.get_renderer() % s_gl_info.get_vendor()).str()); + _L("PrusaSlicer requires OpenGL %s capable graphics driver to run correctly, \n" + "while OpenGL version %s, render %s, vendor %s was detected."), (s_gl_info.is_core_profile() ? "3.3" : "2.0"), s_gl_info.get_version_string(), s_gl_info.get_renderer(), s_gl_info.get_vendor()); #else - _utf8(L("PrusaSlicer requires OpenGL 2.0 capable graphics driver to run correctly, \n" - "while OpenGL version %s, render %s, vendor %s was detected."))) % s_gl_info.get_version_string() % s_gl_info.get_renderer() % s_gl_info.get_vendor()).str()); + _L("PrusaSlicer requires OpenGL 2.0 capable graphics driver to run correctly, \n" + "while OpenGL version %s, render %s, vendor %s was detected."), s_gl_info.get_version_string(), s_gl_info.get_renderer(), s_gl_info.get_vendor()); #endif // ENABLE_OPENGL_ES message += "\n"; message += _L("You may need to update your graphics card driver."); @@ -395,8 +395,7 @@ bool OpenGLManager::init_gl() // load shaders auto [result, error] = m_shaders_manager.init(); if (!result) { - wxString message = from_u8((boost::format( - _utf8(L("Unable to load the following shaders:\n%s"))) % error).str()); + wxString message = format_wxstr(_L("Unable to load the following shaders:\n%s"), error); wxMessageBox(message, wxString("PrusaSlicer - ") + _L("Error loading shaders"), wxOK | wxICON_ERROR); } #if ENABLE_OPENGL_DEBUG_OPTION diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 6a17c4ee5a..08067c5685 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1376,7 +1376,7 @@ void Sidebar::update_sliced_info_sizer() wxString t_est = std::isnan(ps.estimated_print_time) ? "N/A" : get_time_dhms(float(ps.estimated_print_time)); p->sliced_info->SetTextAndShow(siEstimatedTime, t_est, _L("Estimated printing time") + ":"); - p->plater->get_notification_manager()->set_slicing_complete_print_time(_utf8("Estimated printing time: ") + boost::nowide::narrow(t_est), p->plater->is_sidebar_collapsed()); + p->plater->get_notification_manager()->set_slicing_complete_print_time(_u8L("Estimated printing time") + ": " + boost::nowide::narrow(t_est), p->plater->is_sidebar_collapsed()); // Hide non-SLA sliced info parameters p->sliced_info->SetTextAndShow(siFilament_m, "N/A"); @@ -1466,7 +1466,7 @@ void Sidebar::update_sliced_info_sizer() new_label += format_wxstr("\n - %1%", _L("normal mode")); info_text += format_wxstr("\n%1%", short_time(ps.estimated_normal_print_time)); - p->plater->get_notification_manager()->set_slicing_complete_print_time(_utf8("Estimated printing time: ") + ps.estimated_normal_print_time, p->plater->is_sidebar_collapsed()); + p->plater->get_notification_manager()->set_slicing_complete_print_time(_u8L("Estimated printing time") + ": " + ps.estimated_normal_print_time, p->plater->is_sidebar_collapsed()); } if (ps.estimated_silent_print_time != "N/A") { @@ -2343,8 +2343,8 @@ void Plater::priv::collapse_sidebar(bool collapse) // Now update the tooltip in the toolbar. std::string new_tooltip = collapse - ? _utf8(L("Expand sidebar")) - : _utf8(L("Collapse sidebar")); + ? _u8L("Expand sidebar") + : _u8L("Collapse sidebar"); new_tooltip += " [Shift+Tab]"; int id = collapse_toolbar.get_item_id("collapse_sidebar"); collapse_toolbar.set_tooltip(id, new_tooltip); @@ -4251,7 +4251,7 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt) } if (evt.cancelled()) { // this->statusbar()->set_status_text(_L("Cancelled")); - this->notification_manager->set_slicing_progress_canceled(_utf8("Slicing Cancelled.")); + this->notification_manager->set_slicing_progress_canceled(_u8L("Slicing Cancelled.")); } this->sidebar->show_sliced_info_sizer(evt.success()); @@ -4558,7 +4558,7 @@ bool Plater::priv::init_view_toolbar() item.name = "3D"; item.icon_filename = "editor.svg"; - item.tooltip = _utf8(L("3D editor view")) + " [" + GUI::shortkey_ctrl_prefix() + "5]"; + item.tooltip = _u8L("3D editor view") + " [" + GUI::shortkey_ctrl_prefix() + "5]"; item.sprite_id = 0; item.left.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_3D)); }; if (!view_toolbar.add_item(item)) @@ -4566,7 +4566,7 @@ bool Plater::priv::init_view_toolbar() item.name = "Preview"; item.icon_filename = "preview.svg"; - item.tooltip = _utf8(L("Preview")) + " [" + GUI::shortkey_ctrl_prefix() + "6]"; + item.tooltip = _u8L("Preview") + " [" + GUI::shortkey_ctrl_prefix() + "6]"; item.sprite_id = 1; item.left.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_PREVIEW)); }; if (!view_toolbar.add_item(item)) @@ -5437,7 +5437,7 @@ protected: LoadProjectsDialog::LoadProjectsDialog(const std::vector& paths) : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, - from_u8((boost::format(_utf8(L("%s - Multiple projects file"))) % SLIC3R_APP_NAME).str()), wxDefaultPosition, + format_wxstr(_L("%s - Multiple projects file"), SLIC3R_APP_NAME), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) { SetFont(wxGetApp().normal_font()); @@ -5557,7 +5557,7 @@ bool Plater::preview_zip_archive(const boost::filesystem::path& archive_path) mz_zip_zero_struct(&archive); if (!open_zip_reader(&archive, archive_path.string())) { - std::string err_msg = GUI::format(_utf8("Loading of a zip archive on path %1% has failed."), archive_path.string()); + std::string err_msg = GUI::format(_u8L("Loading of a zip archive on path %1% has failed."), archive_path.string()); throw Slic3r::FileIOError(err_msg); } mz_uint num_entries = mz_zip_reader_get_num_files(&archive); @@ -5826,9 +5826,7 @@ protected: ProjectDropDialog::ProjectDropDialog(const std::string& filename) : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, -// #ysFIXME_delete_after_test_of_6377 -// from_u8((boost::format(_utf8(L("%s - Drop project file"))) % SLIC3R_APP_NAME).str()), wxDefaultPosition, - from_u8((boost::format(_utf8(L("%s - Load project file"))) % SLIC3R_APP_NAME).str()), wxDefaultPosition, + format_wxstr(_L("%s - Load project file"), SLIC3R_APP_NAME), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) { SetFont(wxGetApp().normal_font()); diff --git a/src/slic3r/GUI/PresetHints.cpp b/src/slic3r/GUI/PresetHints.cpp index ce709d9eb8..15017ba930 100644 --- a/src/slic3r/GUI/PresetHints.cpp +++ b/src/slic3r/GUI/PresetHints.cpp @@ -163,7 +163,7 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle double volumetric_flow = flow.mm3_per_mm() * (bridging ? bridge_speed : limit_by_first_layer_speed(speed, max_print_speed)); if (max_flow < volumetric_flow) { max_flow = volumetric_flow; - max_flow_extrusion_type = _utf8(err_msg); + max_flow_extrusion_type = GUI::into_u8(_(err_msg)); } }; if (perimeter_extruder_active) { @@ -184,17 +184,17 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle //FIXME handle gap_fill_speed if (! out.empty()) out += "\n"; - out += (first_layer ? _utf8(L("First layer volumetric")) : (bridging ? _utf8(L("Bridging volumetric")) : _utf8(L("Volumetric")))); - out += " " + _utf8(L("flow rate is maximized")) + " "; + out += (first_layer ? _u8L("First layer volumetric") : (bridging ? _u8L("Bridging volumetric") : _u8L("Volumetric"))); + out += " " + _u8L("flow rate is maximized") + " "; bool limited_by_max_volumetric_speed = max_volumetric_speed > 0 && max_volumetric_speed < max_flow; out += (limited_by_max_volumetric_speed ? - _utf8(L("by the print profile maximum")) : - (_utf8(L("when printing"))+ " " + max_flow_extrusion_type)) - + " " + _utf8(L("with a volumetric rate"))+ " "; + _u8L("by the print profile maximum") : + (_u8L("when printing")+ " " + max_flow_extrusion_type)) + + " " + _u8L("with a volumetric rate")+ " "; if (limited_by_max_volumetric_speed) max_flow = max_volumetric_speed; - out += (boost::format(_utf8(L("%3.2f mm³/s at filament speed %3.2f mm/s."))) % max_flow % (max_flow / filament_crossection)).str(); + out += format(_u8L("%3.2f mm³/s at filament speed %3.2f mm/s."), max_flow, (max_flow / filament_crossection)); } return out; @@ -212,13 +212,13 @@ std::string PresetHints::recommended_thin_wall_thickness(const PresetBundle &pre std::string out; if (layer_height <= 0.f) { - out += _utf8(L("Recommended object thin wall thickness: Not available due to invalid layer height.")); + out += _u8L("Recommended object thin wall thickness: Not available due to invalid layer height."); return out; } if (num_perimeters > 0) { int num_lines = std::min(num_perimeters * 2, 10); - out += (boost::format(_utf8(L("Recommended object thin wall thickness for layer height %.2f and"))) % layer_height).str() + " "; + out += (boost::format(_u8L("Recommended object thin wall thickness for layer height %.2f and")) % layer_height).str() + " "; // Start with the width of two closely spaced try { Flow external_perimeter_flow = Flow::new_from_config_width( @@ -233,11 +233,11 @@ std::string PresetHints::recommended_thin_wall_thickness(const PresetBundle &pre for (int i = 2; i <= num_lines; thin_walls ? ++ i : i += 2) { if (i > 2) out += ", "; - out += (boost::format(_utf8(L("%d lines: %.2f mm"))) % i % width).str() + " "; + out += (boost::format(_u8L("%d lines: %.2f mm")) % i % width).str() + " "; width += perimeter_flow.spacing() * (thin_walls ? 1.f : 2.f); } } catch (const FlowErrorNegativeSpacing &) { - out = _utf8(L("Recommended object thin wall thickness: Not available due to excessively small extrusion width.")); + out = _u8L("Recommended object thin wall thickness: Not available due to excessively small extrusion width."); } } return out; @@ -266,7 +266,7 @@ std::string PresetHints::top_bottom_shell_thickness_explanation(const PresetBund double min_layer_height = variable_layer_height ? Slicing::min_layer_height_from_nozzle(printer_config, 1) : layer_height; if (layer_height <= 0.f) { - out += _utf8(L("Top / bottom shell thickness hint: Not available due to invalid layer height.")); + out += _u8L("Top / bottom shell thickness hint: Not available due to invalid layer height."); return out; } @@ -279,13 +279,13 @@ std::string PresetHints::top_bottom_shell_thickness_explanation(const PresetBund top_shell_thickness = n * layer_height; } double top_shell_thickness_minimum = std::max(top_solid_min_thickness, top_solid_layers * min_layer_height); - out += (boost::format(_utf8(L("Top shell is %1% mm thick for layer height %2% mm."))) % top_shell_thickness % layer_height).str(); + out += (boost::format(_u8L("Top shell is %1% mm thick for layer height %2% mm.")) % top_shell_thickness % layer_height).str(); if (variable_layer_height && top_shell_thickness_minimum < top_shell_thickness) { out += " "; - out += (boost::format(_utf8(L("Minimum top shell thickness is %1% mm."))) % top_shell_thickness_minimum).str(); + out += (boost::format(_u8L("Minimum top shell thickness is %1% mm.")) % top_shell_thickness_minimum).str(); } } else - out += _utf8(L("Top is open.")); + out += _u8L("Top is open."); out += "\n"; @@ -298,13 +298,13 @@ std::string PresetHints::top_bottom_shell_thickness_explanation(const PresetBund bottom_shell_thickness = n * layer_height; } double bottom_shell_thickness_minimum = std::max(bottom_solid_min_thickness, bottom_solid_layers * min_layer_height); - out += (boost::format(_utf8(L("Bottom shell is %1% mm thick for layer height %2% mm."))) % bottom_shell_thickness % layer_height).str(); + out += (boost::format(_u8L("Bottom shell is %1% mm thick for layer height %2% mm.")) % bottom_shell_thickness % layer_height).str(); if (variable_layer_height && bottom_shell_thickness_minimum < bottom_shell_thickness) { out += " "; - out += (boost::format(_utf8(L("Minimum bottom shell thickness is %1% mm."))) % bottom_shell_thickness_minimum).str(); + out += (boost::format(_u8L("Minimum bottom shell thickness is %1% mm.")) % bottom_shell_thickness_minimum).str(); } } else - out += _utf8(L("Bottom is open.")); + out += _u8L("Bottom is open."); return out; } diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index f986a15522..b381024aa8 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -473,7 +473,7 @@ void PrintHostQueueDialog::on_error(Event &evt) set_state(evt.job_id, ST_ERROR); - auto errormsg = from_u8((boost::format("%1%\n%2%") % _utf8(L("Error uploading to print host:")) % std::string(evt.status.ToUTF8())).str()); + auto errormsg = format_wxstr("%1%\n%2%", _L("Error uploading to print host") + ":", evt.status); job_list->SetValue(wxVariant(0), evt.job_id, COL_PROGRESS); job_list->SetValue(wxVariant(errormsg), evt.job_id, COL_ERRORMSG); // Stashes the error message into a hidden column for later diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 6e4f64a99e..3cdd846629 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -164,8 +164,8 @@ void Tab::create_preset_tab() m_btn_compare_preset->SetToolTip(_L("Compare this preset with some another")); // TRN "Save current Settings" - m_btn_save_preset->SetToolTip(from_u8((boost::format(_utf8(L("Save current %s"))) % m_title).str())); - m_btn_rename_preset->SetToolTip(from_u8((boost::format(_utf8(L("Rename current %s"))) % m_title).str())); + m_btn_save_preset->SetToolTip(format_wxstr(_L("Save current %s"), m_title)); + m_btn_rename_preset->SetToolTip(format_wxstr(_L("Rename current %s"), m_title)); m_btn_rename_preset->Hide(); m_btn_delete_preset->SetToolTip(_(L("Delete this preset"))); m_btn_delete_preset->Hide(); @@ -3924,7 +3924,7 @@ void Tab::delete_preset() { auto current_preset = m_presets->get_selected_preset(); // Don't let the user delete the ' - default - ' configuration. - std::string action = current_preset.is_external ? _utf8(L("remove")) : _utf8(L("delete")); + wxString action = current_preset.is_external ? _L("remove") : _L("delete"); // TRN remove/delete PhysicalPrinterCollection& physical_printers = m_preset_bundle->physical_printers; @@ -3973,9 +3973,9 @@ void Tab::delete_preset() msg += from_u8((boost::format(_u8L("Are you sure you want to %1% the selected preset?")) % action).str()); } - action = current_preset.is_external ? _utf8(L("Remove")) : _utf8(L("Delete")); + action = current_preset.is_external ? _L("Remove") : _L("Delete"); // TRN Remove/Delete - wxString title = from_u8((boost::format(_utf8(L("%1% Preset"))) % action).str()); //action + _(L(" Preset")); + wxString title = format_wxstr(_L("%1% Preset"), action); if (current_preset.is_default || //wxID_YES != wxMessageDialog(parent(), msg, title, wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal()) wxID_YES != MessageDialog(parent(), msg, title, wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal()) @@ -4061,7 +4061,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep deps.checkbox = new wxCheckBox(parent, wxID_ANY, _(L("All"))); deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font()); wxGetApp().UpdateDarkUI(deps.checkbox, false, true); - deps.btn = new ScalableButton(parent, wxID_ANY, "printer", from_u8((boost::format(" %s %s") % _utf8(L("Set")) % std::string(dots.ToUTF8())).str()), + deps.btn = new ScalableButton(parent, wxID_ANY, "printer", format_wxstr(" %s %s", _L("Set"), dots), wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT); deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font()); deps.btn->SetSize(deps.btn->GetBestSize()); @@ -5024,9 +5024,9 @@ void TabSLAPrint::update_description_lines() { bool elev = !m_config->opt_bool("pad_enable") || !m_config->opt_bool("pad_around_object"); m_support_object_elevation_description_line->SetText(elev ? "" : - from_u8((boost::format(_u8L("\"%1%\" is disabled because \"%2%\" is on in \"%3%\" category.\n" - "To enable \"%1%\", please switch off \"%2%\"")) - % _L("Object elevation") % _L("Pad around object") % _L("Pad")).str())); + format_wxstr(_L("\"%1%\" is disabled because \"%2%\" is on in \"%3%\" category.\n" + "To enable \"%1%\", please switch off \"%2%\"") + , _L("Object elevation"), _L("Pad around object"), _L("Pad"))); } } } diff --git a/src/slic3r/GUI/UpdateDialogs.cpp b/src/slic3r/GUI/UpdateDialogs.cpp index 2b473ae0c6..0d4dc576d9 100644 --- a/src/slic3r/GUI/UpdateDialogs.cpp +++ b/src/slic3r/GUI/UpdateDialogs.cpp @@ -436,8 +436,7 @@ MsgDataIncompatible::~MsgDataIncompatible() {} MsgDataLegacy::MsgDataLegacy() : MsgDialog(nullptr, _(L("Configuration update")), _(L("Configuration update"))) { - auto *text = new wxStaticText(this, wxID_ANY, from_u8((boost::format( - _utf8(L( + auto *text = new wxStaticText(this, wxID_ANY, format_wxstr( _L( "%s now uses an updated configuration structure.\n\n" "So called 'System presets' have been introduced, which hold the built-in default settings for various " @@ -447,10 +446,8 @@ MsgDataLegacy::MsgDataLegacy() : "Please proceed with the %s that follows to set up the new presets " "and to choose whether to enable automatic preset updates." - ))) - % SLIC3R_APP_NAME - % _utf8(ConfigWizard::name())).str() - )); + ) + , SLIC3R_APP_NAME, ConfigWizard::name())); text->Wrap(CONTENT_WIDTH * wxGetApp().em_unit()); content_sizer->Add(text); content_sizer->AddSpacer(VERT_SPACING); @@ -458,7 +455,7 @@ MsgDataLegacy::MsgDataLegacy() : auto *text2 = new wxStaticText(this, wxID_ANY, _(L("For more information please visit our wiki page:"))); static const wxString url("https://github.com/prusa3d/PrusaSlicer/wiki/Slic3r-PE-1.40-configuration-update"); // The wiki page name is intentionally not localized: - auto *link = new wxHyperlinkCtrl(this, wxID_ANY, wxString::Format("%s 1.40 configuration update", SLIC3R_APP_NAME), CONFIG_UPDATE_WIKI_URL); + auto *link = new wxHyperlinkCtrl(this, wxID_ANY, format_wxstr(_L("%s 1.40 configuration update"), SLIC3R_APP_NAME), CONFIG_UPDATE_WIKI_URL); content_sizer->Add(text2); content_sizer->Add(link); content_sizer->AddSpacer(VERT_SPACING); diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index d4bd27c056..f67ad287ae 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -630,9 +630,8 @@ ModeButton::ModeButton( wxWindow* parent, void ModeButton::Init(const wxString &mode) { - std::string mode_str = std::string(mode.ToUTF8()); - m_tt_focused = Slic3r::GUI::from_u8((boost::format(_utf8(L("Switch to the %s mode"))) % mode_str).str()); - m_tt_selected = Slic3r::GUI::from_u8((boost::format(_utf8(L("Current mode is %s"))) % mode_str).str()); + m_tt_focused = Slic3r::GUI::format_wxstr(_L("Switch to the %s mode"), mode); + m_tt_selected = Slic3r::GUI::format_wxstr(_L("Current mode is %s"), mode); SetBitmapMargins(3, 0); diff --git a/src/slic3r/Utils/AppUpdater.cpp b/src/slic3r/Utils/AppUpdater.cpp index 9eb0128271..4c60f018eb 100644 --- a/src/slic3r/Utils/AppUpdater.cpp +++ b/src/slic3r/Utils/AppUpdater.cpp @@ -39,7 +39,7 @@ namespace { std::string msg; bool res = GUI::create_process(path, std::wstring(), msg); if (!res) { - std::string full_message = GUI::format(_utf8("Running downloaded instaler of %1% has failed:\n%2%"), SLIC3R_APP_NAME, msg); + std::string full_message = GUI::format(_u8L("Running downloaded instaler of %1% has failed:\n%2%"), SLIC3R_APP_NAME, msg); BOOST_LOG_TRIVIAL(error) << full_message; // lm: maybe UI error msg? // dk: bellow. (maybe some general show error evt would be better?) wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED); evt->SetString(full_message); @@ -174,9 +174,7 @@ bool AppUpdater::priv::http_get_file(const std::string& url, size_t size_limit, cancel = (m_cancel ? true : !progress_fn(std::move(progress))); if (cancel) { // Lets keep error_message empty here - if there is need to show error dialog, the message will be probably shown by whatever caused the cancel. - /* - error_message = GUI::format(_utf8("Error getting: `%1%`: Download was canceled."), url); - */ + //error_message = GUI::format(_u8L("Error getting: `%1%`: Download was canceled."), url); BOOST_LOG_TRIVIAL(debug) << "AppUpdater::priv::http_get_file message: "<< error_message; } }) @@ -205,8 +203,8 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d assert(!dest_path.empty()); if (dest_path.empty()) { - std::string line1 = GUI::format(_utf8("Internal download error for url %1%:"), data.url); - std::string line2 = _utf8("Destination path is empty."); + std::string line1 = GUI::format(_u8L("Internal download error for url %1%:"), data.url); + std::string line2 = _u8L("Destination path is empty."); std::string message = GUI::format("%1%\n%2%", line1, line2); BOOST_LOG_TRIVIAL(error) << message; wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED); @@ -222,8 +220,8 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d file = fopen(temp_path_wstring.c_str(), "wb"); assert(file != NULL); if (file == NULL) { - std::string line1 = GUI::format(_utf8("Download from %1% couldn't start:"), data.url); - std::string line2 = GUI::format(_utf8("Can't create file at %1%."), tmp_path.string()); + std::string line1 = GUI::format(_u8L("Download from %1% couldn't start:"), data.url); + std::string line2 = GUI::format(_u8L("Can't create file at %1%."), tmp_path.string()); std::string message = GUI::format("%1%\n%2%", line1, line2); BOOST_LOG_TRIVIAL(error) << message; wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED); @@ -264,11 +262,11 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d // Size check. Does always 1 char == 1 byte? size_t body_size = body.size(); if (body_size != expected_size) { - error_message = GUI::format(_utf8("Downloaded file has wrong size. Expected size: %1% Downloaded size: %2%"), expected_size, body_size); + error_message = GUI::format(_u8L("Downloaded file has wrong size. Expected size: %1% Downloaded size: %2%"), expected_size, body_size); return false; } if (file == NULL) { - error_message = GUI::format(_utf8("Can't create file at %1%."), tmp_path.string()); + error_message = GUI::format(_u8L("Can't create file at %1%."), tmp_path.string()); return false; } try @@ -279,7 +277,7 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d } catch (const std::exception& e) { - error_message = GUI::format(_utf8("Failed to write to file or to move %1% to %2%:\n%3%"), tmp_path, dest_path, e.what()); + error_message = GUI::format(_u8L("Failed to write to file or to move %1% to %2%:\n%3%"), tmp_path, dest_path, e.what()); return false; } return true; @@ -295,7 +293,7 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d } else { std::string message = (error_message.empty() ? std::string() - : GUI::format(_utf8("Downloading new %1% has failed:\n%2%"), SLIC3R_APP_NAME, error_message)); + : GUI::format(_u8L("Downloading new %1% has failed:\n%2%"), SLIC3R_APP_NAME, error_message)); wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED); if (!message.empty()) { BOOST_LOG_TRIVIAL(error) << message; diff --git a/src/slic3r/Utils/AstroBox.cpp b/src/slic3r/Utils/AstroBox.cpp index a2b5bca04d..e7044ad20c 100644 --- a/src/slic3r/Utils/AstroBox.cpp +++ b/src/slic3r/Utils/AstroBox.cpp @@ -66,7 +66,7 @@ bool AstroBox::test(wxString &msg) const const auto text = ptree.get_optional("text"); res = validate_version_text(text); if (! res) { - msg = GUI::from_u8((boost::format(_utf8(L("Mismatched type of print host: %s"))) % (text ? *text : "AstroBox")).str()); + msg = GUI::format_wxstr(_L("Mismatched type of print host: %s"), (text ? *text : "AstroBox")); } } catch (const std::exception &) { @@ -86,10 +86,10 @@ wxString AstroBox::get_test_ok_msg () const wxString AstroBox::get_test_failed_msg (wxString &msg) const { - return GUI::from_u8((boost::format("%s: %s\n\n%s") - % _utf8(L("Could not connect to AstroBox")) - % std::string(msg.ToUTF8()) - % _utf8(L("Note: AstroBox version at least 1.1.0 is required."))).str()); + return GUI::format_wxstr("%s: %s\n\n%s" + , _L("Could not connect to AstroBox") + , msg + , _L("Note: AstroBox version at least 1.1.0 is required.")); } bool AstroBox::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const diff --git a/src/slic3r/Utils/Duet.cpp b/src/slic3r/Utils/Duet.cpp index 229d0c950e..74bf080cd8 100644 --- a/src/slic3r/Utils/Duet.cpp +++ b/src/slic3r/Utils/Duet.cpp @@ -49,9 +49,7 @@ wxString Duet::get_test_ok_msg () const wxString Duet::get_test_failed_msg (wxString &msg) const { - return GUI::from_u8((boost::format("%s: %s") - % _utf8(L("Could not connect to Duet")) - % std::string(msg.ToUTF8())).str()); + return GUI::format_wxstr("%s: %s", _L("Could not connect to Duet"), msg); } bool Duet::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const diff --git a/src/slic3r/Utils/FlashAir.cpp b/src/slic3r/Utils/FlashAir.cpp index e54dca58fe..157d9623fc 100644 --- a/src/slic3r/Utils/FlashAir.cpp +++ b/src/slic3r/Utils/FlashAir.cpp @@ -70,10 +70,10 @@ wxString FlashAir::get_test_ok_msg () const wxString FlashAir::get_test_failed_msg (wxString &msg) const { - return GUI::from_u8((boost::format("%s: %s\n%s") - % _utf8(L("Could not connect to FlashAir")) - % std::string(msg.ToUTF8()) - % _utf8(L("Note: FlashAir with firmware 2.00.02 or newer and activated upload function is required."))).str()); + return GUI::format_wxstr("%s: %s\n%s" + , _u8L("Could not connect to FlashAir") + , msg + , _u8L("Note: FlashAir with firmware 2.00.02 or newer and activated upload function is required.")); } bool FlashAir::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const diff --git a/src/slic3r/Utils/MKS.cpp b/src/slic3r/Utils/MKS.cpp index 109283fc66..cce212631d 100644 --- a/src/slic3r/Utils/MKS.cpp +++ b/src/slic3r/Utils/MKS.cpp @@ -57,9 +57,7 @@ wxString MKS::get_test_ok_msg() const wxString MKS::get_test_failed_msg(wxString& msg) const { - return GUI::from_u8((boost::format("%s: %s") - % _utf8(L("Could not connect to MKS")) - % std::string(msg.ToUTF8())).str()); + return GUI::format_wxstr("%s: %s", _L("Could not connect to MKS"), msg); } bool MKS::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const diff --git a/src/slic3r/Utils/OctoPrint.cpp b/src/slic3r/Utils/OctoPrint.cpp index 413a3445ae..d8d977c054 100644 --- a/src/slic3r/Utils/OctoPrint.cpp +++ b/src/slic3r/Utils/OctoPrint.cpp @@ -203,7 +203,7 @@ bool OctoPrint::test_with_resolved_ip(wxString &msg) const const auto text = ptree.get_optional("text"); res = validate_version_text(text); if (!res) { - msg = GUI::from_u8((boost::format(_utf8(L("Mismatched type of print host: %s"))) % (text ? *text : "OctoPrint")).str()); + msg = GUI::format_wxstr(_L("Mismatched type of print host: %s"), (text ? *text : "OctoPrint")); } } catch (const std::exception&) { @@ -252,7 +252,7 @@ bool OctoPrint::test(wxString& msg) const const auto text = ptree.get_optional("text"); res = validate_version_text(text); if (! res) { - msg = GUI::from_u8((boost::format(_utf8(L("Mismatched type of print host: %s"))) % (text ? *text : "OctoPrint")).str()); + msg = GUI::format_wxstr(_L("Mismatched type of print host: %s"), (text ? *text : "OctoPrint")); } } catch (const std::exception &) { @@ -280,10 +280,10 @@ wxString OctoPrint::get_test_ok_msg () const wxString OctoPrint::get_test_failed_msg (wxString &msg) const { - return GUI::from_u8((boost::format("%s: %s\n\n%s") - % _utf8(L("Could not connect to OctoPrint")) - % std::string(msg.ToUTF8()) - % _utf8(L("Note: OctoPrint version at least 1.1.0 is required."))).str()); + return GUI::format_wxstr("%s: %s\n\n%s" + , _L("Could not connect to OctoPrint") + , msg + , _L("Note: OctoPrint version at least 1.1.0 is required.")); } bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const @@ -530,9 +530,7 @@ wxString SL1Host::get_test_ok_msg () const wxString SL1Host::get_test_failed_msg (wxString &msg) const { - return GUI::from_u8((boost::format("%s: %s") - % _utf8(L("Could not connect to Prusa SLA")) - % std::string(msg.ToUTF8())).str()); + return GUI::format_wxstr("%s: %s", _L("Could not connect to Prusa SLA"), msg); } bool SL1Host::validate_version_text(const boost::optional &version_text) const @@ -575,9 +573,7 @@ wxString PrusaLink::get_test_ok_msg() const wxString PrusaLink::get_test_failed_msg(wxString& msg) const { - return GUI::from_u8((boost::format("%s: %s") - % _utf8(L("Could not connect to PrusaLink")) - % std::string(msg.ToUTF8())).str()); + return GUI::format_wxstr("%s: %s", _L("Could not connect to PrusaLink"), msg); } bool PrusaLink::validate_version_text(const boost::optional& version_text) const @@ -663,7 +659,7 @@ bool PrusaLink::test(wxString& msg) const const auto text = ptree.get_optional("text"); res = validate_version_text(text); if (!res) { - msg = GUI::from_u8((boost::format(_utf8(L("Mismatched type of print host: %s"))) % (text ? *text : "OctoPrint")).str()); + msg = GUI::format_wxstr(_L("Mismatched type of print host: %s"), (text ? *text : "OctoPrint")); } } catch (const std::exception&) { @@ -821,7 +817,7 @@ bool PrusaLink::test_with_method_check(wxString& msg, bool& use_put) const const auto text = ptree.get_optional("text"); res = validate_version_text(text); if (!res) { - msg = GUI::from_u8((boost::format(_utf8(L("Mismatched type of print host: %s"))) % (text ? *text : "OctoPrint")).str()); + msg = GUI::format_wxstr(_L("Mismatched type of print host: %s"), (text ? *text : "OctoPrint")); use_put = false; return; } @@ -894,7 +890,7 @@ bool PrusaLink::test_with_resolved_ip_and_method_check(wxString& msg, bool& use_ const auto text = ptree.get_optional("text"); res = validate_version_text(text); if (!res) { - msg = GUI::from_u8((boost::format(_utf8(L("Mismatched type of print host: %s"))) % (text ? *text : "OctoPrint")).str()); + msg = GUI::format_wxstr(_L("Mismatched type of print host: %s"), (text ? *text : "OctoPrint")); use_put = false; return; } diff --git a/src/slic3r/Utils/Repetier.cpp b/src/slic3r/Utils/Repetier.cpp index e266be1f82..274ea4351e 100644 --- a/src/slic3r/Utils/Repetier.cpp +++ b/src/slic3r/Utils/Repetier.cpp @@ -85,7 +85,7 @@ bool Repetier::test(wxString &msg) const const auto soft = ptree.get_optional("software"); res = validate_repetier(text, soft); if (! res) { - msg = GUI::from_u8((boost::format(_utf8(L("Mismatched type of print host: %s"))) % (soft ? *soft : (text ? *text : "Repetier"))).str()); + msg = GUI::format_wxstr(_L("Mismatched type of print host: %s"), (soft ? *soft : (text ? *text : "Repetier"))); } } catch (const std::exception &) { @@ -105,10 +105,10 @@ wxString Repetier::get_test_ok_msg () const wxString Repetier::get_test_failed_msg (wxString &msg) const { - return GUI::from_u8((boost::format("%s: %s\n\n%s") - % _utf8(L("Could not connect to Repetier")) - % std::string(msg.ToUTF8()) - % _utf8(L("Note: Repetier version at least 0.90.0 is required."))).str()); + return GUI::format_wxstr("%s: %s\n\n%s" + , _L("Could not connect to Repetier") + , msg + , _L("Note: Repetier version at least 0.90.0 is required.")); } bool Repetier::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const @@ -142,7 +142,7 @@ bool Repetier::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error auto http = Http::post(std::move(url)); set_auth(http); - if (! upload_data.group.empty() && upload_data.group != _utf8(L("Default"))) { + if (! upload_data.group.empty() && upload_data.group != _u8L("Default")) { http.form_add("group", upload_data.group); } @@ -223,7 +223,7 @@ bool Repetier::get_groups(wxArrayString& groups) const BOOST_FOREACH(boost::property_tree::ptree::value_type &v, ptree.get_child("groupNames.")) { if (v.second.data() == "#") { - groups.push_back(_utf8(L("Default"))); + groups.push_back(_L("Default")); } else { // Is it safe to assume that the data are utf-8 encoded? groups.push_back(GUI::from_u8(v.second.data()));