mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-17 17:02:51 +08:00
Fix wxGETTEXT_IN_CONTEXT* with wxNO_IMPLICIT_WXSTRING_ENCODING
The call to wxGetTranslation() was ambiguous. Fix this by adding missing wxASCII_STR() for all string literal arguments in wxGETTEXT_IN_CONTEXT and wxGETTEXT_IN_CONTEXT_PLURAL, just as it is used in _(). Also test that all translation macros expand to compilable code when wxNO_IMPLICIT_WXSTRING_ENCODING is enabled. See #1312 and also #24916. Closes #24925.
This commit is contained in:
committed by
Vadim Zeitlin
parent
6bcbcf9d09
commit
a47b560fd4
@@ -62,10 +62,10 @@ using wxTranslationsHashMap = std::unordered_map<wxString, wxString>;
|
||||
wxGetTranslation((s), wxString(), c)
|
||||
#else
|
||||
#define wxGETTEXT_IN_CONTEXT(c, s) \
|
||||
wxGetTranslation(wxASCII_STR(s), wxString(), c)
|
||||
wxGetTranslation(wxASCII_STR(s), wxString(), wxASCII_STR(c))
|
||||
#endif
|
||||
#define wxGETTEXT_IN_CONTEXT_PLURAL(c, sing, plur, n) \
|
||||
wxGetTranslation((sing), (plur), n, wxString(), c)
|
||||
wxGetTranslation(wxASCII_STR(sing), wxASCII_STR(plur), n, wxString(), wxASCII_STR(c))
|
||||
|
||||
// another one which just marks the strings for extraction, but doesn't
|
||||
// perform the translation (use -kwxTRANSLATE with xgettext!)
|
||||
|
||||
@@ -413,4 +413,12 @@ TEST_CASE("wxNO_IMPLICIT_WXSTRING_ENCODING", "[string]")
|
||||
#endif
|
||||
|
||||
wxLogSysError(wxASCII_STR("Bogus error for testing"));
|
||||
|
||||
// Check that all translation macros expand to compilable
|
||||
// code also when wxNO_IMPLICIT_WXSTRING_ENCODING is enabled.
|
||||
|
||||
_("some text");
|
||||
wxPLURAL("singular", "plural", 2);
|
||||
wxGETTEXT_IN_CONTEXT("context", "text");
|
||||
wxGETTEXT_IN_CONTEXT_PLURAL("context", "singular", "plural", 3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user