mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-26 04:29:25 -05:00
installer: Use the normalized codeset in the 'locale' field.
* gnu/installer/locale.scm (normalize-codeset): New procedure. (locale->locale-string): Use it.
This commit is contained in:
parent
850ddf94e8
commit
cbd01cff79
1 changed files with 20 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
|
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
|
||||||
|
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -69,6 +70,24 @@ (define (locale-string->locale string)
|
||||||
(codeset . ,(match:substring matches 5))
|
(codeset . ,(match:substring matches 5))
|
||||||
(modifier . ,(match:substring matches 7)))))
|
(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)
|
(define (locale->locale-string locale)
|
||||||
"Reverse operation of locale-string->locale."
|
"Reverse operation of locale-string->locale."
|
||||||
(let ((language (locale-language locale))
|
(let ((language (locale-language locale))
|
||||||
|
@ -81,7 +100,7 @@ (define (locale->locale-string locale)
|
||||||
`("_" ,territory)
|
`("_" ,territory)
|
||||||
'())
|
'())
|
||||||
,@(if codeset
|
,@(if codeset
|
||||||
`("." ,codeset)
|
`("." ,(normalize-codeset codeset))
|
||||||
'())
|
'())
|
||||||
,@(if modifier
|
,@(if modifier
|
||||||
`("@" ,modifier)
|
`("@" ,modifier)
|
||||||
|
|
Loading…
Reference in a new issue