Skip to content

Commit 723b359

Browse files
committed
fixup! Also accept wide string literals as translation macro arguments
1 parent e9ae3e6 commit 723b359

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

include/wx/translation.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,18 @@ inline const wxString& wxGetTranslation(const char *str1,
333333
wxString(context, conv));
334334
}
335335

336-
#define wxTRANS_INPUT_STR(s) wxASCII_STR(s)
337-
#else
336+
// We can't construct wxString implicitly in this case, so use a helper.
337+
inline wxString wxTRANS_INPUT_STR(const char* s)
338+
{
339+
return wxString::FromAscii(s);
340+
}
341+
342+
inline wxString wxTRANS_INPUT_STR(const wchar_t* s)
343+
{
344+
return wxString(s);
345+
}
346+
#else // !wxNO_IMPLICIT_WXSTRING_ENCODING
347+
// We can rely on implicit conversion, so don't bother with the helper.
338348
#define wxTRANS_INPUT_STR(s) s
339349
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
340350

tests/allheaders.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,4 +421,10 @@ TEST_CASE("wxNO_IMPLICIT_WXSTRING_ENCODING", "[string]")
421421
wxPLURAL("singular", "plural", 2);
422422
wxGETTEXT_IN_CONTEXT("context", "text");
423423
wxGETTEXT_IN_CONTEXT_PLURAL("context", "singular", "plural", 3);
424+
425+
// Also wide strings can be used:
426+
_(L"item");
427+
wxGETTEXT_IN_CONTEXT(L"context", L"item");
428+
wxPLURAL(L"sing", L"plur", 3);
429+
wxGETTEXT_IN_CONTEXT_PLURAL(L"context", L"sing", L"plur", 3);
424430
}

tests/intl/intltest.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -796,14 +796,4 @@ TEST_CASE("wxUILocale::ShowSystem", "[.]")
796796
WARN("Preferred UI languages:\n" << preferredLangsStr);
797797
}
798798

799-
// Not an actual test, but a way to ensure that wide string versions
800-
// of translation macros are available and successfully compile.
801-
static void EnsureWideStringVersionsOfMacrosExist() {
802-
// Also wide strings can be used:
803-
_(L"item");
804-
wxGETTEXT_IN_CONTEXT(L"context", L"item");
805-
wxPLURAL(L"sing", L"plur", 3);
806-
wxGETTEXT_IN_CONTEXT_PLURAL(L"context", L"sing", L"plur", 3);
807-
}
808-
809799
#endif // wxUSE_INTL

0 commit comments

Comments
 (0)