summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gran <spk121@yahoo.com>2017-03-20 07:29:47 -0700
committerMike Gran <spk121@yahoo.com>2017-03-20 07:29:47 -0700
commit7e218d35ac96b6a9056aa06f983b3e254b0b9653 (patch)
treed68aa0a950263b9c2a36f898cc57a56da99a760e
parentaa86fcb7d92857ddbd9c0cde40f3d730d4606d62 (diff)
downloadguile-7e218d35ac96b6a9056aa06f983b3e254b0b9653.tar.gz
i18n: rename locale-monetary-digit-grouping to locale-monetary-grouping
* module/ice-9/i18n.scm (locale-monetary-digit-grouping): renamed to locale-monetary grouping (monetary-amount->locale-string): use renamed procedure * test-suite/tests/i18n.test (%french-locale): add LC_MONETARY (%french-utf8-locale): add LC_MONETARY ("nl-langinfo et al."): tests for locale-monetary-grouping
-rw-r--r--module/ice-9/i18n.scm4
-rw-r--r--test-suite/tests/i18n.test27
2 files changed, 26 insertions, 5 deletions
diff --git a/module/ice-9/i18n.scm b/module/ice-9/i18n.scm
index 969c0589b..162049c2d 100644
--- a/module/ice-9/i18n.scm
+++ b/module/ice-9/i18n.scm
@@ -212,7 +212,7 @@
MON_DECIMAL_POINT "")
(define-simple-langinfo-mapping locale-monetary-thousands-separator
MON_THOUSANDS_SEP "")
-(define-simple-langinfo-mapping locale-monetary-digit-grouping
+(define-simple-langinfo-mapping locale-monetary-grouping
MON_GROUPING '())
(define-monetary-langinfo-mapping locale-currency-symbol-precedes-positive?
@@ -387,7 +387,7 @@ locale is used."
(dec (decimal-part
(number-decimal-string (abs amount)
fraction-digits)))
- (grouping (locale-monetary-digit-grouping locale))
+ (grouping (locale-monetary-grouping locale))
(separator (locale-monetary-thousands-separator locale)))
(add-monetary-sign+currency amount
diff --git a/test-suite/tests/i18n.test b/test-suite/tests/i18n.test
index b48f20fac..e7447ebd2 100644
--- a/test-suite/tests/i18n.test
+++ b/test-suite/tests/i18n.test
@@ -117,12 +117,12 @@
(define %french-locale
(false-if-exception
- (make-locale (list LC_CTYPE LC_COLLATE LC_NUMERIC LC_TIME)
+ (make-locale (list LC_CTYPE LC_COLLATE LC_NUMERIC LC_TIME LC_MONETARY)
%french-locale-name)))
(define %french-utf8-locale
(false-if-exception
- (make-locale (list LC_CTYPE LC_COLLATE LC_NUMERIC LC_TIME)
+ (make-locale (list LC_CTYPE LC_COLLATE LC_NUMERIC LC_TIME LC_MONETARY)
%french-utf8-locale-name)))
(define %german-utf8-locale
@@ -482,7 +482,28 @@
(and (string? result)
(string-ci=? result "Tuesday"))))
(lambda ()
- (setlocale LC_ALL "C")))))))
+ (setlocale LC_ALL "C"))))))
+
+ (pass-if "locale-monetary-grouping"
+ ;; In the C locale, there is no rule for grouping of digits
+ ;; of monetary values.
+ (null? (locale-monetary-grouping)))
+
+ (pass-if "locale-monetary-grouping (French)"
+ (under-french-utf8-locale-or-unresolved
+ (lambda ()
+ ;; All systems that have a MON_GROUPING nl_item should know
+ ;; that French monetary values are grouped in 3 digit chunks.
+ ;; Those systems that have no MON_GROUPING nl_item may use the
+ ;; hard-coded default of no grouping.
+ (let ((result (locale-monetary-grouping %french-utf8-locale)))
+ (cond
+ ((null? result)
+ (throw 'unresolved))
+ ((eqv? 3 (false-if-exception (car result)))
+ #t)
+ (else
+ #f)))))))
;;;