guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/05: doc: Factorize 'language-code->native-name'.


From: guix-commits
Subject: 01/05: doc: Factorize 'language-code->native-name'.
Date: Tue, 18 Jan 2022 16:52:13 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit ee16e4e8dac9fd14340cd96731e867134cd843fe
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Jan 18 22:16:12 2022 +0100

    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.
---
 doc/build.scm | 33 ++++++++++++++++++---------------
 1 file 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]