mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 08:11:11 -06:00
Provide a callback to libslic3r to translate texts.
Moved the "translate" functions to namespaces to avoid clashes between the code in libslic3r and Slic3r GUI projects.
This commit is contained in:
parent
6b2b970b9a
commit
02d4f3e14d
6 changed files with 23 additions and 13 deletions
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
#include "../Utils/PresetUpdater.hpp"
|
||||
#include "../Config/Snapshot.hpp"
|
||||
|
||||
#include "libslic3r/I18N.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
|
|
@ -149,9 +149,13 @@ void update_label_colours_from_appconfig()
|
|||
}
|
||||
}
|
||||
|
||||
static std::string libslic3r_translate_callback(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)); }
|
||||
|
||||
void set_wxapp(wxApp *app)
|
||||
{
|
||||
g_wxApp = app;
|
||||
// Let the libslic3r know the callback, which will translate messages on demand.
|
||||
Slic3r::I18N::set_translate_callback(libslic3r_translate_callback);
|
||||
init_label_colours();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,14 @@ class PresetUpdater;
|
|||
class DynamicPrintConfig;
|
||||
class TabIface;
|
||||
|
||||
#define _(s) Slic3r::translate((s))
|
||||
inline wxString translate(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)); }
|
||||
inline wxString translate(const wchar_t *s) { return wxGetTranslation(s); }
|
||||
inline wxString translate(const std::string &s) { return wxGetTranslation(wxString(s.c_str(), wxConvUTF8)); }
|
||||
inline wxString translate(const std::wstring &s) { return wxGetTranslation(s.c_str()); }
|
||||
#define _(s) Slic3r::GUI::I18N::translate((s))
|
||||
|
||||
namespace GUI { namespace I18N {
|
||||
inline wxString translate(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)); }
|
||||
inline wxString translate(const wchar_t *s) { return wxGetTranslation(s); }
|
||||
inline wxString translate(const std::string &s) { return wxGetTranslation(wxString(s.c_str(), wxConvUTF8)); }
|
||||
inline wxString translate(const std::wstring &s) { return wxGetTranslation(s.c_str()); }
|
||||
} }
|
||||
|
||||
// !!! If you needed to translate some wxString,
|
||||
// !!! please use _(L(string))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue