aboutsummaryrefslogtreecommitdiff
path: root/gnu/installer/newt
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/installer/newt')
-rw-r--r--gnu/installer/newt/final.scm9
-rw-r--r--gnu/installer/newt/keymap.scm32
-rw-r--r--gnu/installer/newt/locale.scm30
-rw-r--r--gnu/installer/newt/page.scm7
-rw-r--r--gnu/installer/newt/timezone.scm5
5 files changed, 60 insertions, 23 deletions
diff --git a/gnu/installer/newt/final.scm b/gnu/installer/newt/final.scm
index 645c1e8689..f492c5dbb7 100644
--- a/gnu/installer/newt/final.scm
+++ b/gnu/installer/newt/final.scm
@@ -65,22 +65,23 @@ press the button to reboot.")))
(G_ "The final system installation step failed. You can retry the \
last step, or restart the installer.")))
-(define (run-install-shell)
+(define (run-install-shell locale)
(clear-screen)
(newt-suspend)
- (let ((install-ok? (install-system)))
+ (let ((install-ok? (install-system locale)))
(newt-resume)
install-ok?))
(define (run-final-page result prev-steps)
- (let* ((configuration (format-configuration prev-steps result))
+ (let* ((configuration (format-configuration prev-steps result))
(user-partitions (result-step result 'partition))
+ (locale (result-step result 'locale))
(install-ok?
(with-mounted-partitions
user-partitions
(configuration->file configuration)
(run-config-display-page)
- (run-install-shell))))
+ (run-install-shell locale))))
(if install-ok?
(run-install-success-page)
(run-install-failed-page))))
diff --git a/gnu/installer/newt/keymap.scm b/gnu/installer/newt/keymap.scm
index 948b54783c..2908ba7f0e 100644
--- a/gnu/installer/newt/keymap.scm
+++ b/gnu/installer/newt/keymap.scm
@@ -28,6 +28,7 @@
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
+ #:use-module (ice-9 i18n)
#:use-module (ice-9 match)
#:export (run-keymap-page
keyboard-layout->configuration))
@@ -64,14 +65,29 @@
(define (sort-layouts layouts)
"Sort LAYOUTS list by putting the US layout ahead and return it."
+ (define (layout<? layout1 layout2)
+ (let ((text1 (x11-keymap-layout-description layout1))
+ (text2 (x11-keymap-layout-description layout2)))
+ ;; XXX: We're calling 'gettext' more than once per item.
+ (string-locale<? (gettext text1 "xkeyboard-config")
+ (gettext text2 "xkeyboard-config"))))
+
+ (define preferred
+ ;; Two-letter language tag for the preferred keyboard layout.
+ (or (getenv "LANGUAGE") "us"))
+
(call-with-values
(lambda ()
(partition
(lambda (layout)
- (let ((name (x11-keymap-layout-name layout)))
- (string=? name "us")))
+ ;; The 'synopsis' field is usually a language code (e.g., "en")
+ ;; while the 'name' field is a country code (e.g., "us").
+ (or (string=? (x11-keymap-layout-name layout) preferred)
+ (string=? (x11-keymap-layout-synopsis layout) preferred)))
layouts))
- (cut append <> <>)))
+ (lambda (main others)
+ (append (sort main layout<?)
+ (sort others layout<?)))))
(define (sort-variants variants)
"Sort VARIANTS list by putting the international variant ahead and return it."
@@ -97,7 +113,8 @@ names of the selected keyboard layout and variant."
(run-layout-page
(sort-layouts layouts)
(lambda (layout)
- (x11-keymap-layout-description layout))))))
+ (gettext (x11-keymap-layout-description layout)
+ "xkeyboard-config"))))))
;; Propose the user to select a variant among those supported by the
;; previously selected layout.
(installer-step
@@ -111,15 +128,16 @@ names of the selected keyboard layout and variant."
(run-variant-page
(sort-variants variants)
(lambda (variant)
- (x11-keymap-variant-description
- variant))))))))))
+ (gettext (x11-keymap-variant-description variant)
+ "xkeyboard-config"))))))))))
(define (format-result result)
(let ((layout (x11-keymap-layout-name
(result-step result 'layout)))
(variant (and=> (result-step result 'variant)
(lambda (variant)
- (x11-keymap-variant-name variant)))))
+ (gettext (x11-keymap-variant-name variant)
+ "xkeyboard-config")))))
(list layout (or variant ""))))
(format-result
(run-installer-steps #:steps keymap-steps)))
diff --git a/gnu/installer/newt/locale.scm b/gnu/installer/newt/locale.scm
index b819d06691..7108e2960b 100644
--- a/gnu/installer/newt/locale.scm
+++ b/gnu/installer/newt/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.
;;;
@@ -30,9 +31,9 @@
#:export (run-locale-page))
(define (run-language-page languages language->text)
- (let ((title (G_ "Locale language")))
+ (define result
(run-listbox-selection-page
- #:title title
+ #:title (G_ "Locale language")
#:info-text (G_ "Choose the language to use for the \
installation process and for the installed system.")
#:info-textbox-width 70
@@ -44,7 +45,13 @@ installation process and for the installed system.")
(lambda _
(raise
(condition
- (&installer-step-abort)))))))
+ (&installer-step-abort))))))
+
+ ;; Immediately install the chosen language so that the territory page that
+ ;; comes after (optionally) is displayed in the chosen language.
+ (setenv "LANGUAGE" result)
+
+ result)
(define (run-territory-page territories territory->text)
(let ((title (G_ "Locale location")))
@@ -155,7 +162,13 @@ glibc locale string and return it."
(run-language-page
(sort-languages
(delete-duplicates (map locale-language supported-locales)))
- (cut language-code->language-name iso639-languages <>)))))
+ (lambda (language)
+ (let ((english (language-code->language-name iso639-languages
+ language)))
+ (setenv "LANGUAGE" language)
+ (let ((native (gettext english "iso_639-3")))
+ (unsetenv "LANGUAGE")
+ native)))))))
(installer-step
(id 'territory)
(compute
@@ -169,10 +182,11 @@ glibc locale string and return it."
;; supported by the previously selected language.
(run-territory-page
(delete-duplicates (map locale-territory locales))
- (lambda (territory-code)
- (if territory-code
- (territory-code->territory-name iso3166-territories
- territory-code)
+ (lambda (territory)
+ (if territory
+ (let ((english (territory-code->territory-name
+ iso3166-territories territory)))
+ (gettext english "iso_3166-1"))
(G_ "No location"))))))))
(installer-step
(id 'codeset)
diff --git a/gnu/installer/newt/page.scm b/gnu/installer/newt/page.scm
index 8b3fd488e9..5c650652bd 100644
--- a/gnu/installer/newt/page.scm
+++ b/gnu/installer/newt/page.scm
@@ -21,6 +21,7 @@
#:use-module (gnu installer utils)
#:use-module (gnu installer newt utils)
#:use-module (guix i18n)
+ #:use-module (ice-9 i18n)
#:use-module (ice-9 match)
#:use-module (ice-9 receive)
#:use-module (srfi srfi-1)
@@ -223,7 +224,7 @@ be selected (using the <SPACE> key). It that case, a list containing the
selected items will be returned.
If SORT-LISTBOX-ITEMS? is set to #t, the listbox items are sorted using
-'string<=' procedure (after being converted to text).
+'string-locale<?' procedure (after being converted to text).
If ALLOW-DELETE? is #t, the form will return if the <DELETE> key is pressed,
otherwise nothing will happen.
@@ -249,7 +250,7 @@ ITEM was inserted into LISTBOX."
items))
(define (sort-listbox-items listbox-items)
- "Return LISTBOX-ITEMS sorted using the 'string<=' procedure on the text
+ "Return LISTBOX-ITEMS sorted using the 'string-locale<?' procedure on the text
corresponding to each item in the list."
(let* ((items (map (lambda (item)
(cons item (listbox-item->text item)))
@@ -258,7 +259,7 @@ corresponding to each item in the list."
(sort items (lambda (a b)
(let ((text-a (cdr a))
(text-b (cdr b)))
- (string<= text-a text-b))))))
+ (string-locale<? text-a text-b))))))
(map car sorted-items)))
;; Store the last selected listbox item's key.
diff --git a/gnu/installer/newt/timezone.scm b/gnu/installer/newt/timezone.scm
index 63b44af729..67bf41ff84 100644
--- a/gnu/installer/newt/timezone.scm
+++ b/gnu/installer/newt/timezone.scm
@@ -50,12 +50,15 @@ returned."
(define (run-page timezone-tree)
(define (loop path)
+ ;; XXX: Translation of time zones isn't perfect here because the
+ ;; "iso_3166-1" domain contains translation for "territories" (like
+ ;; "Antarctic") but not for continents (like "Africa").
(let ((timezones (locate-children timezone-tree path)))
(run-listbox-selection-page
#:title (G_ "Timezone")
#:info-text (G_ "Please select a timezone.")
#:listbox-items timezones
- #:listbox-item->text identity
+ #:listbox-item->text (cut gettext <> "iso_3166-1")
#:button-text (if (null? path)
(G_ "Exit")
(G_ "Back"))