2018-11-26 13:41:58 +00:00
|
|
|
#ifndef _
|
|
|
|
#define _(s) Slic3r::GUI::I18N::translate((s))
|
2019-05-09 15:18:03 +00:00
|
|
|
#define _utf8(s) Slic3r::GUI::I18N::translate_utf8((s))
|
2018-11-26 13:41:58 +00:00
|
|
|
#endif /* _ */
|
|
|
|
|
2019-01-22 16:52:14 +00:00
|
|
|
#ifndef _CTX
|
|
|
|
#define _CTX(s, ctx) Slic3r::GUI::I18N::translate((s), (ctx))
|
2019-05-09 15:18:03 +00:00
|
|
|
#define _CTX_utf8(s, ctx) Slic3r::GUI::I18N::translate_utf8((s), (ctx))
|
2019-01-22 16:52:14 +00:00
|
|
|
#endif /* _ */
|
|
|
|
|
2018-11-26 13:41:58 +00:00
|
|
|
#ifndef L
|
|
|
|
// !!! If you needed to translate some wxString,
|
|
|
|
// !!! please use _(L(string))
|
|
|
|
// !!! _() - is a standard wxWidgets macro to translate
|
|
|
|
// !!! L() is used only for marking localizable string
|
|
|
|
// !!! It will be used in "xgettext" to create a Locating Message Catalog.
|
|
|
|
#define L(s) s
|
|
|
|
#endif /* L */
|
|
|
|
|
2019-08-27 15:14:03 +00:00
|
|
|
#ifndef L_CONTEXT
|
|
|
|
#define L_CONTEXT(s, context) s
|
|
|
|
#endif /* L */
|
|
|
|
|
2018-11-26 13:41:58 +00:00
|
|
|
#ifndef _CHB
|
|
|
|
//! macro used to localization, return wxScopedCharBuffer
|
|
|
|
//! With wxConvUTF8 explicitly specify that the source string is already in UTF-8 encoding
|
|
|
|
#define _CHB(s) wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str()
|
|
|
|
#endif /* _CHB */
|
|
|
|
|
|
|
|
#ifndef slic3r_GUI_I18N_hpp_
|
|
|
|
#define slic3r_GUI_I18N_hpp_
|
|
|
|
|
|
|
|
#include <wx/intl.h>
|
2019-01-22 16:52:14 +00:00
|
|
|
#include <wx/version.h>
|
2018-11-26 13:41:58 +00:00
|
|
|
|
|
|
|
namespace Slic3r { 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()); }
|
2019-01-22 16:52:14 +00:00
|
|
|
|
2019-05-09 15:18:03 +00:00
|
|
|
inline std::string translate_utf8(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).ToUTF8().data(); }
|
|
|
|
inline std::string translate_utf8(const wchar_t *s) { return wxGetTranslation(s).ToUTF8().data(); }
|
|
|
|
inline std::string translate_utf8(const std::string &s) { return wxGetTranslation(wxString(s.c_str(), wxConvUTF8)).ToUTF8().data(); }
|
|
|
|
inline std::string translate_utf8(const std::wstring &s) { return wxGetTranslation(s.c_str()).ToUTF8().data(); }
|
|
|
|
|
2019-01-22 16:52:14 +00:00
|
|
|
#if wxCHECK_VERSION(3, 1, 1)
|
|
|
|
#define _wxGetTranslation_ctx(S, CTX) wxGetTranslation((S), wxEmptyString, (CTX))
|
|
|
|
#else
|
|
|
|
#define _wxGetTranslation_ctx(S, CTX) ((void)(CTX), wxGetTranslation((S)))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
inline wxString translate(const char *s, const char* ctx) { return _wxGetTranslation_ctx(wxString(s, wxConvUTF8), ctx); }
|
|
|
|
inline wxString translate(const wchar_t *s, const char* ctx) { return _wxGetTranslation_ctx(s, ctx); }
|
|
|
|
inline wxString translate(const std::string &s, const char* ctx) { return _wxGetTranslation_ctx(wxString(s.c_str(), wxConvUTF8), ctx); }
|
|
|
|
inline wxString translate(const std::wstring &s, const char* ctx) { return _wxGetTranslation_ctx(s.c_str(), ctx); }
|
|
|
|
|
2019-05-09 15:18:03 +00:00
|
|
|
inline wxString translate_utf8(const char *s, const char* ctx) { return _wxGetTranslation_ctx(wxString(s, wxConvUTF8), ctx).ToUTF8().data(); }
|
|
|
|
inline wxString translate_utf8(const wchar_t *s, const char* ctx) { return _wxGetTranslation_ctx(s, ctx).ToUTF8().data(); }
|
|
|
|
inline wxString translate_utf8(const std::string &s, const char* ctx) { return _wxGetTranslation_ctx(wxString(s.c_str(), wxConvUTF8), ctx).ToUTF8().data(); }
|
|
|
|
inline wxString translate_utf8(const std::wstring &s, const char* ctx) { return _wxGetTranslation_ctx(s.c_str(), ctx).ToUTF8().data(); }
|
|
|
|
|
2019-01-22 16:52:14 +00:00
|
|
|
#undef _wxGetTranslation_ctx
|
|
|
|
}
|
2018-11-26 13:41:58 +00:00
|
|
|
|
|
|
|
// Return translated std::string as a wxString
|
|
|
|
wxString L_str(const std::string &str);
|
|
|
|
|
|
|
|
} }
|
|
|
|
|
|
|
|
#endif /* slic3r_GUI_I18N_hpp_ */
|