From 04d0aa99059e4925dcfb55d4d9a550f225948612 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 7 Apr 2019 12:11:55 +0200 Subject: installer: Simplify locale dialogs. * gnu/installer/newt/locale.scm (run-language-page): Simplify text. (run-territory-page): Likewise. (run-codeset-page): Likewise. (run-locale-page): Don't call 'run-codeset-page' when "UTF-8" is among the codesets of LOCALES. --- gnu/installer/newt/locale.scm | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'gnu/installer/newt/locale.scm') diff --git a/gnu/installer/newt/locale.scm b/gnu/installer/newt/locale.scm index 4fa07df81e..b819d06691 100644 --- a/gnu/installer/newt/locale.scm +++ b/gnu/installer/newt/locale.scm @@ -33,14 +33,8 @@ (let ((title (G_ "Locale language"))) (run-listbox-selection-page #:title title - #:info-text (G_ "Choose the locale's language to be used for the \ -installation process. A locale is a regional variant of your language \ -encompassing number, date and currency format, among other details. - -Based on the language you choose, you will possibly be asked to \ -select a locale's territory, codeset and modifier in the next \ -steps. The locale will also be used as the default one for the \ -installed system.") + #:info-text (G_ "Choose the language to use for the \ +installation process and for the installed system.") #:info-textbox-width 70 #:listbox-items languages #:listbox-item->text language->text @@ -56,8 +50,7 @@ installed system.") (let ((title (G_ "Locale location"))) (run-listbox-selection-page #:title title - #:info-text (G_ "Choose your locale's location. This is a shortlist of \ -locations based on the language you selected.") + #:info-text (G_ "Choose a territory for this language.") #:listbox-items territories #:listbox-item->text territory->text #:button-text (G_ "Back") @@ -71,8 +64,7 @@ locations based on the language you selected.") (let ((title (G_ "Locale codeset"))) (run-listbox-selection-page #:title title - #:info-text (G_ "Choose your locale's codeset. If UTF-8 is available, \ - it should be preferred.") + #:info-text (G_ "Choose the locale encoding.") #:listbox-items codesets #:listbox-item->text identity #:listbox-default-item "UTF-8" @@ -191,9 +183,11 @@ glibc locale string and return it." ;; narrow down the search of a locale. (break-on-locale-found locales) - ;; Otherwise, ask for a codeset. - (run-codeset-page - (delete-duplicates (map locale-codeset locales))))))) + ;; Otherwise, choose a codeset. + (let ((codesets (delete-duplicates (map locale-codeset locales)))) + (if (member "UTF-8" codesets) + "UTF-8" ;don't even ask + (run-codeset-page codesets))))))) (installer-step (id 'modifier) (compute -- cgit 1.4.1 From 2d5867a213c4d23882e463d599eb236032086250 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 17 Apr 2019 10:34:02 +0200 Subject: installer: Change language as soon as it has been chosen. Previously we'd call 'setlocale' only after the complete 'locale' step had finished. * gnu/installer/newt/locale.scm (run-language-page): Set the 'LANGUAGE' environment variable before returning. --- gnu/installer/newt/locale.scm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'gnu/installer/newt/locale.scm') diff --git a/gnu/installer/newt/locale.scm b/gnu/installer/newt/locale.scm index b819d06691..01bcf76025 100644 --- a/gnu/installer/newt/locale.scm +++ b/gnu/installer/newt/locale.scm @@ -30,9 +30,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 +44,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"))) -- cgit 1.4.1 From 7837a57241775fed221c9e03700af73263e222ed Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 17 Apr 2019 11:07:21 +0200 Subject: installer: Display language and territory names natively. * gnu/installer.scm (installer-program): Add calls to 'bindtextdomain'. * gnu/installer/newt/locale.scm (run-locale-page) : Add calls to 'gettext'. --- gnu/installer.scm | 10 ++++++++++ gnu/installer/newt/locale.scm | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'gnu/installer/newt/locale.scm') diff --git a/gnu/installer.scm b/gnu/installer.scm index 6a7a556271..5baead8137 100644 --- a/gnu/installer.scm +++ b/gnu/installer.scm @@ -343,6 +343,16 @@ selected keymap." ;; Add some binaries used by the installers to PATH. #$set-installer-path + ;; Arrange for language and territory name translations to be + ;; available. We need them at run time, not just compile time, + ;; because some territories have several corresponding languages + ;; (e.g., "French" is always displayed as "français", but + ;; "Belgium" could be translated to Dutch, French, or German.) + (bindtextdomain "iso_639-3" ;languages + #+(file-append iso-codes "/share/locale")) + (bindtextdomain "iso_3166-1" ;territories + #+(file-append iso-codes "/share/locale")) + (let* ((current-installer newt-installer) (steps (#$steps current-installer))) ((installer-init current-installer)) diff --git a/gnu/installer/newt/locale.scm b/gnu/installer/newt/locale.scm index 01bcf76025..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 +;;; Copyright © 2019 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -161,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 @@ -175,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) -- cgit 1.4.1