Explicit encoding for implicit conversion in wxGetTranslation()
This commit is contained in:
committed by
Vadim Zeitlin
parent
c86bcf962d
commit
860f6076b8
@@ -300,6 +300,42 @@ inline const wxString& wxGetTranslation(const wxString& str1,
|
|||||||
: wxTranslations::GetUntranslatedString(str2);
|
: wxTranslations::GetUntranslatedString(str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get and set the default encoding for strings to be translated.
|
||||||
|
* These are only useful when the wxNO_IMPLICIT_WXSTRING_ENCODING macro is
|
||||||
|
* defined.
|
||||||
|
*/
|
||||||
|
WXDLLIMPEXP_BASE const wxMBConv &wxGetInlineEncoding();
|
||||||
|
|
||||||
|
WXDLLIMPEXP_BASE void wxSetInlineEncoding(const wxMBConv &conv);
|
||||||
|
|
||||||
|
#ifdef wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
|
||||||
|
/*
|
||||||
|
* It must always be possible to call wxGetTranslation() with const
|
||||||
|
* char* arguments.
|
||||||
|
*/
|
||||||
|
inline const wxString& wxGetTranslation(const char *str,
|
||||||
|
const char *domain = "",
|
||||||
|
const char *context = "") {
|
||||||
|
const wxMBConv &conv = wxGetInlineEncoding();
|
||||||
|
return wxGetTranslation(wxString(str, conv), wxString(domain, conv),
|
||||||
|
wxString(context, conv));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const wxString& wxGetTranslation(const char *str1,
|
||||||
|
const char *str2,
|
||||||
|
unsigned n,
|
||||||
|
const char *domain = "",
|
||||||
|
const char *context = "") {
|
||||||
|
const wxMBConv &conv = wxGetInlineEncoding();
|
||||||
|
return wxGetTranslation(wxString(str1, conv), wxString(str2, conv), n,
|
||||||
|
wxString(domain, conv),
|
||||||
|
wxString(context, conv));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
|
||||||
#else // !wxUSE_INTL
|
#else // !wxUSE_INTL
|
||||||
|
|
||||||
// the macros should still be defined - otherwise compilation would fail
|
// the macros should still be defined - otherwise compilation would fail
|
||||||
|
@@ -2110,4 +2110,16 @@ public:
|
|||||||
|
|
||||||
wxIMPLEMENT_DYNAMIC_CLASS(wxTranslationsModule, wxModule);
|
wxIMPLEMENT_DYNAMIC_CLASS(wxTranslationsModule, wxModule);
|
||||||
|
|
||||||
|
// Encoding for strings to be translated, passed as const char *.
|
||||||
|
static const wxMBConv *inlineEncoding = &wxConvLibc;
|
||||||
|
|
||||||
|
WXDLLIMPEXP_BASE const wxMBConv &wxGetInlineEncoding() {
|
||||||
|
return *inlineEncoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
WXDLLIMPEXP_BASE void wxSetInlineEncoding(const wxMBConv &conv) {
|
||||||
|
inlineEncoding = &conv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // wxUSE_INTL
|
#endif // wxUSE_INTL
|
||||||
|
Reference in New Issue
Block a user