diff options
author | bubnikv <bubnikv@gmail.com> | 2019-08-28 17:19:46 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2019-08-28 17:19:46 +0300 |
commit | 8865c4b685e8af646ee0517c3c2ab6e53daf7782 (patch) | |
tree | 3f3e81c2ea4c5168ba91464abb6a835ae3f6efd9 /src/slic3r/GUI/I18N.hpp | |
parent | 2b7a4973a86c3679dd495ccbb223076293fe0343 (diff) |
Plurals for number of Undo / Redo actions.
Diffstat (limited to 'src/slic3r/GUI/I18N.hpp')
-rw-r--r-- | src/slic3r/GUI/I18N.hpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/slic3r/GUI/I18N.hpp b/src/slic3r/GUI/I18N.hpp index 13c119b99..bf3103f77 100644 --- a/src/slic3r/GUI/I18N.hpp +++ b/src/slic3r/GUI/I18N.hpp @@ -36,16 +36,26 @@ 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 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()); } - 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 wxString translate(const char *s, const char *plural, unsigned int n) { return wxGetTranslation(wxString(s, wxConvUTF8), wxString(plural, wxConvUTF8), n); } + inline wxString translate(const wchar_t *s, const wchar_t *plural, unsigned int n) { return wxGetTranslation(s, plural, n); } + inline wxString translate(const std::string &s, const std::string &plural, unsigned int n) { return wxGetTranslation(wxString(s.c_str(), wxConvUTF8), wxString(plural.c_str(), wxConvUTF8), n); } + inline wxString translate(const std::wstring &s, const std::wstring &plural, unsigned int n) { return wxGetTranslation(s.c_str(), plural.c_str(), n); } + + 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(); } + inline std::string translate_utf8(const char *s, const char *plural, unsigned int n) { return translate(s, plural, n).ToUTF8().data(); } + inline std::string translate_utf8(const wchar_t *s, const wchar_t *plural, unsigned int n) { return translate(s, plural, n).ToUTF8().data(); } + inline std::string translate_utf8(const std::string &s, const std::string &plural, unsigned int n) { return translate(s, plural, n).ToUTF8().data(); } + inline std::string translate_utf8(const std::wstring &s, const std::wstring &plural, unsigned int n) { return translate(s, plural, n).ToUTF8().data(); } + #if wxCHECK_VERSION(3, 1, 1) #define _wxGetTranslation_ctx(S, CTX) wxGetTranslation((S), wxEmptyString, (CTX)) #else @@ -63,11 +73,17 @@ namespace I18N { inline wxString translate_utf8(const std::wstring &s, const char* ctx) { return _wxGetTranslation_ctx(s.c_str(), ctx).ToUTF8().data(); } #undef _wxGetTranslation_ctx -} +} // namespace I18N // Return translated std::string as a wxString wxString L_str(const std::string &str); -} } +} // namespace GUI +} // namespace Slic3r + +// Macro to function both as a marker for xgettext and to actually perform the translation. +#ifndef _L_PLURAL +#define _L_PLURAL(s, plural, n) Slic3r::GUI::I18N::translate(s, plural, n) +#endif /* L */ #endif /* slic3r_GUI_I18N_hpp_ */ |