diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-11-16 03:02:07 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-11-22 00:00:05 +0100 |
commit | 965b3b9d0ad3faa337ecdc8db1565e1a5819b13a (patch) | |
tree | fb089d0926cf0c408e1ebbd83780c7c53d7b1aa2 /module/hnh/util/language.scm | |
parent | Add tests for language utilities. (diff) | |
download | calp-965b3b9d0ad3faa337ecdc8db1565e1a5819b13a.tar.gz calp-965b3b9d0ad3faa337ecdc8db1565e1a5819b13a.tar.xz |
Empty env vars equals unset when resolving language.
Diffstat (limited to 'module/hnh/util/language.scm')
-rw-r--r-- | module/hnh/util/language.scm | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/module/hnh/util/language.scm b/module/hnh/util/language.scm index 9b61483c..f393f179 100644 --- a/module/hnh/util/language.scm +++ b/module/hnh/util/language.scm @@ -1,6 +1,12 @@ (define-module (hnh util language) :export (resolve-language)) +;;; Given a #f or a string, return #f if #f or an empty string is given, +;;; and the given string otherwise +(define (falsify-string s) + (cond ((and (boolean? s) (not s)) s) + ((string-null? s) #f) + (else s))) ;; Locale objects, such as %global-locale, doesn't provide a way to access the language name, ;; This is for procedures which want to handle their translations manually. @@ -8,7 +14,7 @@ "Returns a two character symbol representing the \"current\" language. e.g. en" (string->symbol (string-take - (or (getenv "LC_MESSAGES") - (getenv "LC_ALL") + (or (falsify-string (getenv "LC_MESSAGES")) + (falsify-string (getenv "LC_ALL")) "en") 2))) |