mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Expose C_ function (gettext with context string) to guile code
First use is for the document link short code (L)
This commit is contained in:
parent
5bbfdec79a
commit
dae2ea8356
@ -28,6 +28,7 @@
|
||||
#include <gnc-filepath-utils.h>
|
||||
#include <gnc-locale-utils.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <gnc-version.h>
|
||||
#include <libintl.h>
|
||||
|
||||
@ -158,6 +159,20 @@ gchar *gnc_locale_name (void);
|
||||
|
||||
%rename ("gnc:gettext") gettext;
|
||||
extern const char* gettext(const char*);
|
||||
%rename ("gnc:C_gettext") wrap_C_;
|
||||
%inline %{
|
||||
/* This helper function wraps the C_() macro in to 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)
|
||||
{
|
||||
gchar* combo = g_strconcat (context, "\004", msg, NULL);
|
||||
const gchar* translated = g_dpgettext (NULL, combo, strlen (context) + 1);
|
||||
g_free (combo);
|
||||
return translated;
|
||||
}
|
||||
%}
|
||||
%rename ("gnc-utf8?") wrap_gnc_utf8_validate;
|
||||
%inline %{
|
||||
/* This helper function wraps gnc_utf8_validate() into a predicate. */
|
||||
|
@ -27,6 +27,7 @@
|
||||
(define-module (gnucash core-utils)
|
||||
#:export (N_
|
||||
G_
|
||||
C_
|
||||
gnc:version))
|
||||
|
||||
;; Guile 2 needs to find the symbols from the extension at compile time already
|
||||
@ -42,6 +43,7 @@
|
||||
|
||||
;; gettext functions
|
||||
(define G_ gnc:gettext)
|
||||
(define C_ gnc:C-gettext)
|
||||
(define-syntax-rule (N_ x) x)
|
||||
|
||||
;; the following will define _ to call gnc:gettext for guile up to
|
||||
|
@ -1255,8 +1255,8 @@ be excluded from periodic reporting.")
|
||||
(gnc:html-transaction-doclink-anchor
|
||||
(xaccSplitGetParent split)
|
||||
;; Translators: 'L' is short for Linked Document
|
||||
(G_ "L"))
|
||||
(G_ "L"))))))))
|
||||
(C_ "Column header for 'Document Link'" "L"))
|
||||
(C_ "Column header for 'Document Link'" "L"))))))))
|
||||
|
||||
(add-if (column-uses? 'price)
|
||||
(vector (G_ "Price")
|
||||
|
Loading…
Reference in New Issue
Block a user