[PATCH 13/13] N_ in the root module

Andy Wingo wingo at pobox.com
Tue Mar 30 04:19:27 EDT 2010


* src/app-utils/app-utils.scm:
* src/app-utils/c-interface.scm: Make N_ available to all of Gnucash. A
  hack, but a correct hack that permits the Scheme code to be compiled.
---
 src/app-utils/app-utils.scm   |   16 ++++++++++++++++
 src/app-utils/c-interface.scm |    9 ---------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/app-utils/app-utils.scm b/src/app-utils/app-utils.scm
index 7126f96..4491ccc 100644
--- a/src/app-utils/app-utils.scm
+++ b/src/app-utils/app-utils.scm
@@ -260,6 +260,22 @@
 (define gnc:*kvp-option-path* (list BOOK-OPTIONS-NAME))
 (export gnc:*kvp-option-path*)
 
+;; gettext functions
+(define gnc:gettext gnc-gettext-helper)
+(define gnc:_ gnc:gettext)
+(define _ gnc:gettext)
+(define-syntax N_
+  (syntax-rules ()
+    ((_ x) x)))
+
+;; A lot of Gnucash's code uses procedural interfaces to load modules.
+;; This normally works, for procedures -- but for values that need to be
+;; known at expand time, like macros, it doesn't work (in Guile 2.0 at
+;; least). So instead of auditing all the code, since N_ is really the
+;; only Gnucash-defined macro in use, the surgical solution is just to
+;; make N_ available everywhere.
+(module-define! the-root-module 'N_ (module-ref (current-module) 'N_))
+
 (load-from-path "c-interface.scm")
 (load-from-path "config-var.scm")
 (load-from-path "options.scm")
diff --git a/src/app-utils/c-interface.scm b/src/app-utils/c-interface.scm
index 55db837..223ee5a 100644
--- a/src/app-utils/c-interface.scm
+++ b/src/app-utils/c-interface.scm
@@ -37,15 +37,6 @@
    (call-with-output-string write-error)))
 
 
-;; gettext functions
-(define gnc:gettext gnc-gettext-helper)
-(define gnc:_ gnc:gettext)
-(define _ gnc:gettext)
-(define-syntax N_
-  (syntax-rules ()
-    ((_ x) x)))
-
-
 ;; This database can be used to store and retrieve translatable
 ;; strings. Strings that are returned by the lookup function are
 ;; translated with gettext.
-- 
1.6.2.5


--=-=-=


Cheers,

Andy
-- 
http://wingolog.org/

--=-=-=--


More information about the gnucash-devel mailing list