summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/scm/webid-oidc/web-i18n.scm18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/scm/webid-oidc/web-i18n.scm b/src/scm/webid-oidc/web-i18n.scm
index 54d0c36..978e6a4 100644
--- a/src/scm/webid-oidc/web-i18n.scm
+++ b/src/scm/webid-oidc/web-i18n.scm
@@ -51,7 +51,7 @@
((? string?
(= (cute string-split <> #\-)
((? string? lang)
- (? string? region))))
+ (? string? (= string-upcase region)))))
(format #f "~a_~a.UTF-8" lang region))
(else "")))
@@ -67,22 +67,24 @@
;; Translation done, nothing to do
out))
+(define (set-lc-all locale)
+ (catch #t
+ (lambda ()
+ (setlocale LC_ALL locale))
+ (lambda error
+ (setlocale LC_ALL "C"))))
+
(define (web-gettext str)
(let ((out
(with-mutex locale-mutex
(let ((previous-locale (setlocale LC_ALL)))
(dynamic-wind
(lambda ()
- (with-exception-handler
- (lambda (exn)
- (setlocale LC_ALL "C"))
- (lambda ()
- (setlocale LC_ALL (web-locale)))
- #:unwind? #t))
+ (set-lc-all (web-locale)))
(lambda ()
(gettext str))
(lambda ()
- (setlocale LC_ALL previous-locale)))))))
+ (set-lc-all previous-locale)))))))
(disambiguate str out)))
(define (sysadmin-gettext str)