From 5b0c648a7c5ac3d827bb6fc61b3b2037a2d4b62c Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 4 Jul 2018 10:52:59 +0200 Subject: profiles: 'info-dir-file' hook now produces 'dir.LANG' files. Previously, entries for 'guix.fr.info' would end up in 'dir', above the 'guix.info' entries; consequently, running 'info guix' would actually open 'guix.fr.info', which was confusing for non-French readers. * guix/profiles.scm (info-dir-file)[glibc-utf8-locales]: New variable. [build](info-file-language): New procedure. (install-info): Use it, to create 'dir.LANG' files. Set GUIX_LOCPATH. --- guix/profiles.scm | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/guix/profiles.scm b/guix/profiles.scm index ebd7da2a24..e6b77e8d38 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -703,6 +703,8 @@ (define texinfo ;lazy reference (module-ref (resolve-interface '(gnu packages texinfo)) 'texinfo)) (define gzip ;lazy reference (module-ref (resolve-interface '(gnu packages compression)) 'gzip)) + (define glibc-utf8-locales ;lazy reference + (module-ref (resolve-interface '(gnu packages base)) 'glibc-utf8-locales)) (define build (with-imported-modules '((guix build utils)) @@ -720,11 +722,31 @@ (define (info-files top) (map (cut string-append infodir "/" <>) (or (scandir infodir info-file?) '())))) + (define (info-file-language file) + (let* ((base (if (string-suffix? ".gz" file) + (basename file ".info.gz") + (basename file ".info"))) + (dot (string-rindex base #\.))) + (if dot + (string-drop base (+ 1 dot)) + "en"))) + (define (install-info info) - (setenv "PATH" (string-append #+gzip "/bin")) ;for info.gz files - (zero? - (system* (string-append #+texinfo "/bin/install-info") "--silent" - info (string-append #$output "/share/info/dir")))) + (let ((language (info-file-language info))) + ;; We need to choose a valid locale for $LANGUAGE to be honored. + (setenv "LC_ALL" "en_US.utf8") + (setenv "LANGUAGE" language) + (zero? + (system* #+(file-append texinfo "/bin/install-info") + "--silent" info + (apply string-append #$output "/share/info/dir" + (if (string=? "en" language) + '("") + `("." ,language))))))) + + (setenv "PATH" (string-append #+gzip "/bin")) ;for info.gz files + (setenv "GUIX_LOCPATH" + #+(file-append glibc-utf8-locales "/lib/locale")) (mkdir-p (string-append #$output "/share/info")) (exit (every install-info -- cgit v1.2.3