Add wxTRANSLATE_IN_CONTEXT() macro for marking strings for translation

Similarly to wxTRANSLATE(), this macro does not do much itself.
This commit is contained in:
Lauri Nurmi 2022-04-23 21:31:21 +03:00
parent 5d5591816d
commit e3bf759615
3 changed files with 19 additions and 1 deletions

View File

@ -61,6 +61,11 @@
// perform the translation (use -kwxTRANSLATE with xgettext!)
#define wxTRANSLATE(str) str
// another one which just marks the strings, with a context, for extraction,
// but doesn't perform the translation (use -kwxTRANSLATE_IN_CONTEXT:1c,2 with
// xgettext!)
#define wxTRANSLATE_IN_CONTEXT(c, str) str
// ----------------------------------------------------------------------------
// forward decls
// ----------------------------------------------------------------------------
@ -345,6 +350,7 @@ inline const wxString& wxGetTranslation(const char *str1,
#endif
#define wxTRANSLATE(str) str
#define wxTRANSLATE_IN_CONTEXT(c, str) str
// NB: we use a template here in order to avoid using
// wxLocale::GetUntranslatedString() above, which would be required if

View File

@ -521,6 +521,18 @@ public:
*/
#define wxTRANSLATE(string)
/**
This macro doesn't do anything in the program code -- it simply expands to
the value of its argument.
Similar to wxTRANSLATE(), but with a context argument. Both the context and
string need to be string literals. Be sure to use the same context when
calling wxGetTranslation().
@since 3.1.7
*/
#define wxTRANSLATE_IN_CONTEXT(context, string)
/**
This function returns the translation of @a string in the current
@c locale().

View File

@ -16,7 +16,7 @@ XGETTEXT=xgettext
XARGS=xargs
# common xgettext args: C++ syntax, use the specified macro names as markers
XGETTEXT_ARGS=-C -k_ -kwxPLURAL:1,2 -kwxGETTEXT_IN_CONTEXT:1c,2 -kwxGETTEXT_IN_CONTEXT_PLURAL:1c,2,3 -kwxTRANSLATE -kwxGetTranslation --add-comments=TRANSLATORS: -j
XGETTEXT_ARGS=-C -k_ -kwxPLURAL:1,2 -kwxGETTEXT_IN_CONTEXT:1c,2 -kwxGETTEXT_IN_CONTEXT_PLURAL:1c,2,3 -kwxTRANSLATE -kwxTRANSLATE_IN_CONTEXT:1c,2 -kwxGetTranslation --add-comments=TRANSLATORS: -j
# implicit rules
%.mo: %.po