summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-04-07 16:19:09 +0200
committerLudovic Courtès <ludo@gnu.org>2019-04-07 16:19:09 +0200
commitcbd01cff797750e38b1c3061761d41398b53c86b (patch)
treee4bb6e3abe59b4a4d16eae1ae44deee036ae6a84
parent850ddf94e86a1711328e39872c7830ad6d5020b4 (diff)
installer: Use the normalized codeset in the 'locale' field.
* gnu/installer/locale.scm (normalize-codeset): New procedure. (locale->locale-string): Use it.
-rw-r--r--gnu/installer/locale.scm21
1 files changed, 20 insertions, 1 deletions
diff --git a/gnu/installer/locale.scm b/gnu/installer/locale.scm
index 2b45b2200a..284062a6e7 100644
--- a/gnu/installer/locale.scm
+++ b/gnu/installer/locale.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -69,6 +70,24 @@
(codeset . ,(match:substring matches 5))
(modifier . ,(match:substring matches 7)))))
+(define (normalize-codeset codeset)
+ "Compute the \"normalized\" variant of CODESET."
+ ;; info "(libc) Using gettextized software", for the algorithm used to
+ ;; compute the normalized codeset.
+ (letrec-syntax ((-> (syntax-rules ()
+ ((_ proc value)
+ (proc value))
+ ((_ proc rest ...)
+ (proc (-> rest ...))))))
+ (-> (lambda (str)
+ (if (string-every char-set:digit str)
+ (string-append "iso" str)
+ str))
+ string-downcase
+ (lambda (str)
+ (string-filter char-set:letter+digit str))
+ codeset)))
+
(define (locale->locale-string locale)
"Reverse operation of locale-string->locale."
(let ((language (locale-language locale))
@@ -81,7 +100,7 @@
`("_" ,territory)
'())
,@(if codeset
- `("." ,codeset)
+ `("." ,(normalize-codeset codeset))
'())
,@(if modifier
`("@" ,modifier)