[core-utils.i] Use g_dpgettext2 instead of g_dpgettext

avoids using \004 context and msg separator.

Discussed in dae2ea8356
This commit is contained in:
Christopher Lam 2022-04-02 09:08:19 +08:00
parent 842c4879a6
commit 11458bf8b3

View File

@ -171,16 +171,11 @@ extern const char* ngettext (const char *msgid1, const char *msgid2,
extern const char* gettext(const char*); extern const char* gettext(const char*);
%rename ("gnc:C_gettext") wrap_C_; %rename ("gnc:C_gettext") wrap_C_;
%inline %{ %inline %{
/* This helper function wraps the C_() macro in to a function. /* This helper function wraps the C_() macro in a function. */
Direct wrapping results in a compiler error on direct string concatenation
inside the macro expansion, so I'm making a detour via g_strconcat */
const char* wrap_C_(const char* context, const char* msg); const char* wrap_C_(const char* context, const char* msg);
const char* wrap_C_(const char* context, const char* msg) const char* wrap_C_(const char* context, const char* msg)
{ {
gchar* combo = g_strconcat (context, "\004", msg, NULL); return g_dpgettext2 (NULL, context, msg);
const gchar* translated = g_dpgettext (NULL, combo, strlen (context) + 1);
g_free (combo);
return translated;
} }
%} %}
%rename ("gnc-utf8?") wrap_gnc_utf8_validate; %rename ("gnc-utf8?") wrap_gnc_utf8_validate;