app-utils - simplify and move gettext wrappers

1. Instead of creating a C wrapper around gettext to then wrap in
guile, use guile's builtin gettext support directly.

The code still defines the _ and N_ shorthands. However it doesn't
really warant a separate module just for these two shorthands.
Instead define them in core-utils. So all code wanting to use
_ or N_ in guile should now use the (gnucash core-utils) module.

The bulk of this commit is actually deleting the scm-gettext
target and using (gnucash core-utils) instead of (gnucash gettext).

2. As the definition of _ and N_ is removed from app-utils.scm,
the app-utils test for a functional N_ macro has been moved to a
new test file in the guile bindinds tests.

3. The (gnucash gettext) module has been deprecated. Use
(gnucash core-utils) from now on.
This commit is contained in:
Geert Janssens
2019-11-10 18:15:34 +01:00
parent 759bbe1da0
commit d777128e6f
78 changed files with 102 additions and 226 deletions

View File

@@ -37,3 +37,9 @@
(module-use! i (resolve-interface '(sw_core_utils))))
(define-public gnc:version (gnc-version))
;; gettext functions
(define-public _ gettext)
(define-syntax N_
(syntax-rules ()
((_ x) x)))
(export N_)

View File

@@ -24,7 +24,8 @@ gnc_add_test_with_guile(test-scm-query test-scm-query.cpp ENGINE_TEST_INCLUDE_DI
# Scheme tests
set(engine_test_SCHEME
set(bindings_test_SCHEME
test-core-utils.scm
test-create-account.scm
)
@@ -33,6 +34,7 @@ set(engine_test_SCHEME
set(GUILE_DEPENDS
scm-gnc-module
scm-app-utils
scm-core-utils
scm-engine)
gnc_add_scheme_test_targets(scm-test-engine-extras
@@ -46,7 +48,7 @@ gnc_add_scheme_test_targets(scm-test-engine-extras
gnc_add_scheme_deprecated_module ("gnucash engine test test-extras" "tests test-engine-extras" "scm-test-engine-extras" "")
gnc_add_scheme_test_targets(scm-test-engine
"${engine_test_SCHEME}"
"${bindings_test_SCHEME}"
"tests"
"${GUILE_DEPENDS};scm-test-engine-extras"
FALSE
@@ -113,7 +115,7 @@ endif (HAVE_SRFI64)
set(test_engine_SCHEME_DIST
srfi64-extras.scm
test-create-account.scm
${bindings_test_SCHEME}
test-engine-extras.scm
test-scm-query-import.scm
test-business-core.scm

View File

@@ -0,0 +1,17 @@
(define exit-code 0)
(setenv "GNC_UNINSTALLED" "1")
(use-modules (gnucash core-utils))
(if (macro? (module-ref (current-module) 'N_))
(display "Macro N_ defined\n")
(begin
(display "Failed - macro N_ not defined\n")
(set! exit-code -1)))
(if (string=? (N_ "foobar") "foobar")
(display "Macro N_ works properly\n")
(begin
(display "Failed - macro N_ doesn't work\n")
(set! exit-code -1)))
(exit exit-code)