diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2016-02-10 11:01:54 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2016-02-10 15:15:17 +0100 |
| commit | f5582b2c1d7cb73f36d5278bec99d7279f813a39 (patch) | |
| tree | 1af4e61e8aa258338e4eeb9e0b5d4c78fe3a7a8f /gnu/system | |
| parent | 32e16112064ae3f7bad729802834c965b270bbc0 (diff) | |
system: Selected locale is automatically built.
Fixes <http://bugs.gnu.org/22572>.
Reported by Mark H Weaver <mhw@netris.org>.
* gnu/system/locale.scm (%not-dot): New variable.
(denormalize-codeset, locale-name->definition): New procedures.
* gnu/system.scm (locale-name->definition*): New procedure.
(operating-system-locale-directory): Instead of raising an error, add
the missing locale.
* doc/guix.texi (Locales): Adjust accordingly.
Diffstat (limited to 'gnu/system')
| -rw-r--r-- | gnu/system/locale.scm | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/gnu/system/locale.scm b/gnu/system/locale.scm index e798827a018..f9d713e0cfd 100644 --- a/gnu/system/locale.scm +++ b/gnu/system/locale.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; This file is part of GNU Guix. | 4 | ;;; This file is part of GNU Guix. |
| 5 | ;;; | 5 | ;;; |
| @@ -33,6 +33,7 @@ | |||
| 33 | locale-definition-source | 33 | locale-definition-source |
| 34 | locale-definition-charset | 34 | locale-definition-charset |
| 35 | 35 | ||
| 36 | locale-name->definition | ||
| 36 | locale-directory | 37 | locale-directory |
| 37 | 38 | ||
| 38 | %default-locale-libcs | 39 | %default-locale-libcs |
| @@ -52,6 +53,35 @@ | |||
| 52 | (charset locale-definition-charset ;string--e.g., "UTF-8" | 53 | (charset locale-definition-charset ;string--e.g., "UTF-8" |
| 53 | (default "UTF-8"))) | 54 | (default "UTF-8"))) |
| 54 | 55 | ||
| 56 | (define %not-dot | ||
| 57 | (char-set-complement (char-set #\.))) | ||
| 58 | |||
| 59 | (define (denormalize-codeset codeset) | ||
| 60 | "Attempt to guess the \"real\" name of CODESET, a normalized codeset as | ||
| 61 | defined in (info \"(libc) Using gettextized software\")." | ||
| 62 | (cond ((string=? codeset "utf8") | ||
| 63 | "UTF-8") | ||
| 64 | ((string-prefix? "iso8859" codeset) | ||
| 65 | (string-append "ISO-8859-" (string-drop codeset 7))) | ||
| 66 | ((string=? codeset "eucjp") | ||
| 67 | "EUC-JP") | ||
| 68 | (else ;cross fingers, hope for the best | ||
| 69 | codeset))) | ||
| 70 | |||
| 71 | (define (locale-name->definition name) | ||
| 72 | "Return a <locale-definition> corresponding to NAME, guessing the charset, | ||
| 73 | or #f on failure." | ||
| 74 | (match (string-tokenize name %not-dot) | ||
| 75 | ((source charset) | ||
| 76 | ;; XXX: NAME is supposed to use the "normalized codeset", such as "utf8", | ||
| 77 | ;; whereas the actual name used is different. Add a special case to make | ||
| 78 | ;; the right guess for UTF-8. | ||
| 79 | (locale-definition (name name) | ||
| 80 | (source source) | ||
| 81 | (charset (denormalize-codeset charset)))) | ||
| 82 | (_ | ||
| 83 | #f))) | ||
| 84 | |||
| 55 | (define* (localedef-command locale | 85 | (define* (localedef-command locale |
| 56 | #:key (libc (canonical-package glibc))) | 86 | #:key (libc (canonical-package glibc))) |
| 57 | "Return a gexp that runs 'localedef' from LIBC to build LOCALE." | 87 | "Return a gexp that runs 'localedef' from LIBC to build LOCALE." |
