From 096e49e15b0bcb84c92de4afc35f54931a489994 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 27 Feb 2024 11:38:35 +0100 Subject: [PATCH] core: make translate() accessible from C++ In the core, we usually want C strings, not QStrings. Therefore, make translated C strings directly available from C++. Signed-off-by: Berthold Stoeger --- core/gettext.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/gettext.h b/core/gettext.h index ed2f56d78..806154007 100644 --- a/core/gettext.h +++ b/core/gettext.h @@ -2,10 +2,22 @@ #ifndef MYGETTEXT_H #define MYGETTEXT_H +#ifdef __cplusplus + +extern "C" const char *trGettext(const char *); +static inline const char *translate(const char *, const char *arg) +{ + return trGettext(arg); +} + +#else + /* this is for the Qt based translations */ extern const char *trGettext(const char *); #define translate(_context, arg) trGettext(arg) #define QT_TRANSLATE_NOOP(_context, arg) arg #define QT_TRANSLATE_NOOP3(_context, arg, _comment) arg +#endif + #endif // MYGETTEXT_H