diff --git a/src/slic3r/Utils/AstroBox.cpp b/src/slic3r/Utils/AstroBox.cpp index 20560f1c1..8392b6e8f 100644 --- a/src/slic3r/Utils/AstroBox.cpp +++ b/src/slic3r/Utils/AstroBox.cpp @@ -79,17 +79,13 @@ bool AstroBox::test(wxString &msg) const return res; } -wxString AstroBox::get_test_ok_msg () const -{ - return _(L("Connection to AstroBox works correctly.")); -} - 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")) + % (boost::format(_u8L("Could not connect to %s")) % get_name()) % std::string(msg.ToUTF8()) - % _utf8(L("Note: AstroBox version at least 1.1.0 is required."))).str()); + % _u8L("Note: AstroBox version at least 1.1.0 is required.") + ).str()); } bool AstroBox::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const diff --git a/src/slic3r/Utils/AstroBox.hpp b/src/slic3r/Utils/AstroBox.hpp index f24018b1b..8b064f81b 100644 --- a/src/slic3r/Utils/AstroBox.hpp +++ b/src/slic3r/Utils/AstroBox.hpp @@ -21,7 +21,6 @@ public: const char* get_name() const override; bool test(wxString &curl_msg) const override; - wxString get_test_ok_msg () const override; wxString get_test_failed_msg (wxString &msg) const override; bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override; bool has_auto_discovery() const override { return true; } diff --git a/src/slic3r/Utils/Duet.cpp b/src/slic3r/Utils/Duet.cpp index ba93603a1..c51897b37 100644 --- a/src/slic3r/Utils/Duet.cpp +++ b/src/slic3r/Utils/Duet.cpp @@ -42,18 +42,6 @@ bool Duet::test(wxString &msg) const return connectionType != ConnectionType::error; } -wxString Duet::get_test_ok_msg () const -{ - return _(L("Connection to Duet works correctly.")); -} - -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()); -} - bool Duet::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const { wxString connect_msg; diff --git a/src/slic3r/Utils/Duet.hpp b/src/slic3r/Utils/Duet.hpp index e5aec548b..615ea60a2 100644 --- a/src/slic3r/Utils/Duet.hpp +++ b/src/slic3r/Utils/Duet.hpp @@ -20,8 +20,6 @@ public: const char* get_name() const override; bool test(wxString &curl_msg) const override; - wxString get_test_ok_msg() const override; - wxString get_test_failed_msg(wxString &msg) const override; bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override; bool has_auto_discovery() const override { return false; } bool can_test() const override { return true; } diff --git a/src/slic3r/Utils/FlashAir.cpp b/src/slic3r/Utils/FlashAir.cpp index 22eaddece..cdf943ac0 100644 --- a/src/slic3r/Utils/FlashAir.cpp +++ b/src/slic3r/Utils/FlashAir.cpp @@ -63,17 +63,12 @@ bool FlashAir::test(wxString &msg) const return res; } -wxString FlashAir::get_test_ok_msg () const -{ - return _(L("Connection to FlashAir works correctly and upload is enabled.")); -} - 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")) + % (boost::format(_u8L("Could not connect to %s")) % get_name()) % std::string(msg.ToUTF8()) - % _utf8(L("Note: FlashAir with firmware 2.00.02 or newer and activated upload function is required."))).str()); + % _u8L("Note: FlashAir with firmware 2.00.02 or newer and activated upload function is required.")).str()); } bool FlashAir::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const diff --git a/src/slic3r/Utils/FlashAir.hpp b/src/slic3r/Utils/FlashAir.hpp index 181405d46..b5c6eaa15 100644 --- a/src/slic3r/Utils/FlashAir.hpp +++ b/src/slic3r/Utils/FlashAir.hpp @@ -21,7 +21,6 @@ public: const char* get_name() const override; bool test(wxString &curl_msg) const override; - wxString get_test_ok_msg() const override; wxString get_test_failed_msg(wxString &msg) const override; bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override; bool has_auto_discovery() const override { return false; } diff --git a/src/slic3r/Utils/OctoPrint.cpp b/src/slic3r/Utils/OctoPrint.cpp index b3fe215d9..9dc9b4e74 100644 --- a/src/slic3r/Utils/OctoPrint.cpp +++ b/src/slic3r/Utils/OctoPrint.cpp @@ -78,14 +78,13 @@ bool OctoPrint::test(wxString &msg) const return res; } -wxString OctoPrint::get_test_ok_msg () const -{ - return wxString::Format(_(L("Connection to %s works correctly.")), get_name()); -} - wxString OctoPrint::get_test_failed_msg (wxString &msg) const { - return wxString::Format("%s: %s\n\n%s", wxString::Format(_(L("Could not connect to %s")), get_name()), msg, _(L("Note: OctoPrint version at least 1.1.0 is required."))); + return GUI::from_u8((boost::format("%s: %s\n\n%s") + % (boost::format(_u8L("Could not connect to %s")) % get_name()) + % std::string(msg.ToUTF8()) + % _u8L("Note: OctoPrint version at least 1.1.0 is required.") + ).str()); } bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const diff --git a/src/slic3r/Utils/OctoPrint.hpp b/src/slic3r/Utils/OctoPrint.hpp index bd6365394..c91dc5834 100644 --- a/src/slic3r/Utils/OctoPrint.hpp +++ b/src/slic3r/Utils/OctoPrint.hpp @@ -24,7 +24,6 @@ public: const char* get_name() const; bool test(wxString &curl_msg) const override; - wxString get_test_ok_msg () const override; wxString get_test_failed_msg (wxString &msg) const override; bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override; bool has_auto_discovery() const override { return true; } diff --git a/src/slic3r/Utils/PrintHost.cpp b/src/slic3r/Utils/PrintHost.cpp index 4f7728540..455494277 100644 --- a/src/slic3r/Utils/PrintHost.cpp +++ b/src/slic3r/Utils/PrintHost.cpp @@ -20,6 +20,7 @@ #include "Repetier.hpp" #include "Klipper.hpp" #include "../GUI/PrintHostDialogs.hpp" +#include "slic3r/GUI/I18N.hpp" namespace fs = boost::filesystem; using boost::optional; @@ -30,6 +31,19 @@ namespace Slic3r { PrintHost::~PrintHost() {} + +wxString PrintHost::get_test_ok_msg() const +{ + return wxString::Format(_L("Connection to %s works correctly."), get_name()); +} + +wxString PrintHost::get_test_failed_msg(wxString& msg) const +{ + return GUI::from_u8((boost::format("%s: %s") + % (boost::format(_u8L("Could not connect to %s")) % get_name()) + % std::string(msg.ToUTF8())).str()); +} + PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config) { PrinterTechnology tech = ptFFF; diff --git a/src/slic3r/Utils/PrintHost.hpp b/src/slic3r/Utils/PrintHost.hpp index 35a870b29..52be7bd4c 100644 --- a/src/slic3r/Utils/PrintHost.hpp +++ b/src/slic3r/Utils/PrintHost.hpp @@ -39,8 +39,8 @@ public: virtual const char* get_name() const = 0; virtual bool test(wxString &curl_msg) const = 0; - virtual wxString get_test_ok_msg () const = 0; - virtual wxString get_test_failed_msg (wxString &msg) const = 0; + virtual wxString get_test_ok_msg () const; + virtual wxString get_test_failed_msg (wxString &msg) const; virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const = 0; virtual bool has_auto_discovery() const = 0; virtual bool can_test() const = 0; diff --git a/src/slic3r/Utils/Repetier.cpp b/src/slic3r/Utils/Repetier.cpp index 115ea010e..c3c24c38e 100644 --- a/src/slic3r/Utils/Repetier.cpp +++ b/src/slic3r/Utils/Repetier.cpp @@ -66,7 +66,7 @@ bool Repetier::test(wxString &msg) const const auto text = ptree.get_optional("name"); res = validate_version_text(text); if (! res) { - msg = GUI::from_u8((boost::format(_utf8(L("Mismatched type of print host: %s"))) % (text ? *text : "Repetier")).str()); + msg = GUI::from_u8((boost::format(_u8L("Mismatched type of print host: %s")) % (text ? *text : "Repetier")).str()); } } catch (const std::exception &) { @@ -79,17 +79,12 @@ bool Repetier::test(wxString &msg) const return res; } -wxString Repetier::get_test_ok_msg () const -{ - return _(L("Connection to Repetier works correctly.")); -} - 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")) + % (boost::format(_u8L("Could not connect to %s")) % get_name()) % std::string(msg.ToUTF8()) - % _utf8(L("Note: Repetier version at least 0.90.0 is required."))).str()); + % _u8L("Note: Repetier version at least 0.90.0 is required.")).str()); } bool Repetier::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const diff --git a/src/slic3r/Utils/Repetier.hpp b/src/slic3r/Utils/Repetier.hpp index d94d7ec56..ee5d17426 100644 --- a/src/slic3r/Utils/Repetier.hpp +++ b/src/slic3r/Utils/Repetier.hpp @@ -22,7 +22,6 @@ public: const char* get_name() const; bool test(wxString &curl_msg) const override; - wxString get_test_ok_msg () const override; wxString get_test_failed_msg (wxString &msg) const override; bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override; bool has_auto_discovery() const override { return false; }