aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-01-18 22:16:12 +0100
committerLudovic Courtès <ludo@gnu.org>2022-01-18 22:51:08 +0100
commitee16e4e8dac9fd14340cd96731e867134cd843fe (patch)
tree78ca7c2fba40b656ede34a65ee414da496d3bc7b /doc
parent3a751156896478fb65b5290ff4324d7203edae6f (diff)
downloadguix-ee16e4e8dac9fd14340cd96731e867134cd843fe.tar
guix-ee16e4e8dac9fd14340cd96731e867134cd843fe.tar.gz
doc: Factorize 'language-code->native-name'.
* doc/build.scm (localization-helper-module)[content](translate): Add call to 'setenv' before 'write'. Remove use of 'with-language'. (language-code->native-name): New procedure. (html-manual-indexes)[build](top-level-index): Use it.
Diffstat (limited to 'doc')
-rw-r--r--doc/build.scm33
1 files changed, 18 insertions, 15 deletions
diff --git a/doc/build.scm b/doc/build.scm
index 7282809643..1057336c65 100644
--- a/doc/build.scm
+++ b/doc/build.scm
@@ -842,6 +842,7 @@ must be the Guix top-level source directory, from which PO files are taken."
with-language
translate
language-code->name
+ language-code->native-name
seconds->string))
(define (normalize language) ;XXX: deduplicate
@@ -876,19 +877,19 @@ must be the Guix top-level source directory, from which PO files are taken."
(bindtextdomain "iso_639-3" ;language names
#+(file-append iso-codes
"/share/locale"))
+ (setenv "LANGUAGE" ,language)
(write (gettext ,str ,domain))))
- (with-language language
- ;; Since the 'gettext' function caches msgid translations,
- ;; regardless of $LANGUAGE, we have to spawn a new process each
- ;; time we want to translate to a different language. Bah!
- (let* ((pipe (open-pipe* OPEN_READ
- #+(file-append guile-3.0
- "/bin/guile")
- "-c" (object->string exp)))
- (str (read pipe)))
- (close-pipe pipe)
- str)))
+ ;; Since the 'gettext' function caches msgid translations,
+ ;; regardless of $LANGUAGE, we have to spawn a new process each
+ ;; time we want to translate to a different language. Bah!
+ (let* ((pipe (open-pipe* OPEN_READ
+ #+(file-append guile-3.0
+ "/bin/guile")
+ "-c" (object->string exp)))
+ (str (read pipe)))
+ (close-pipe pipe)
+ str))
(define %iso639-languages
(vector->list
@@ -910,6 +911,11 @@ must be the Guix top-level source directory, from which PO files are taken."
(assoc-ref language "name")))
%iso639-languages)))
+ (define (language-code->native-name code)
+ "Return the name of language CODE in that language."
+ (translate (language-code->name code) code
+ #:domain "iso_639-3"))
+
(define (seconds->string seconds language)
(let* ((time (make-time time-utc 0 seconds))
(date (time-utc->date time)))
@@ -1026,10 +1032,7 @@ languages:\n"
(ul
,@(map (lambda (language)
`(li (a (@ (href ,(normalize language)))
- ,(translate
- (language-code->name language)
- language
- #:domain "iso_639-3"))))
+ ,(language-code->native-name language))))
languages)))))))
(define (write-html file sxml)