guix-commits
[Top][All Lists]
Advanced

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

02/05: self: translate-texi-manuals: Don't hardcode "guix.texi".


From: guix-commits
Subject: 02/05: self: translate-texi-manuals: Don't hardcode "guix.texi".
Date: Tue, 21 Apr 2020 17:53:09 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit cc753650eccf3dcbf074999c458e42df8d3c0827
Author: Ludovic Courtès <address@hidden>
AuthorDate: Tue Apr 21 21:50:34 2020 +0200

    self: translate-texi-manuals: Don't hardcode "guix.texi".
    
    * guix/self.scm (translate-texi-manuals)[build](translate-texi): Add
    'prefix' and #:extras parameters and honor them.  Adjust callers.
---
 guix/self.scm | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/guix/self.scm b/guix/self.scm
index 1040c27..93dcb9b 100644
--- a/guix/self.scm
+++ b/guix/self.scm
@@ -339,35 +339,35 @@ TRANSLATIONS, an alist of msgid and msgstr."
                              #f regexp1 content 'pre "ref{" msgstr "," 'post)
                            'pre "ref{" msgstr "}" 'post))))))
               content translations))
-          
-          (define (translate-texi po lang)
-            "Translate the manual for one language LANG using the PO file."
+
+          (define* (translate-texi prefix po lang
+                                   #:key (extras '()))
+            "Translate the manual for one language LANG using the PO file.
+PREFIX must be the prefix of the manual, 'guix' or 'guix-cookbook'.  EXTRAS is
+a list of extra files, such as '(\"contributing\")."
             (let ((translations (call-with-input-file po read-po-file)))
-              (translate-tmp-texi po "guix.texi"
-                                  (string-append "guix." lang ".texi.tmp"))
-              (translate-tmp-texi po "contributing.texi"
-                                  (string-append "contributing." lang 
".texi.tmp"))
-              (let* ((texi-name (string-append "guix." lang ".texi"))
-                     (tmp-name (string-append texi-name ".tmp")))
-                (with-output-to-file texi-name
-                  (lambda _
-                    (format #t "~a"
-                      (translate-cross-references
-                        (call-with-input-file tmp-name get-string-all)
-                        translations)))))
-              (let* ((texi-name (string-append "contributing." lang ".texi"))
-                     (tmp-name (string-append texi-name ".tmp")))
-                (with-output-to-file texi-name
-                  (lambda _
-                    (format #t "~a"
-                      (translate-cross-references
-                        (call-with-input-file tmp-name get-string-all)
-                        translations)))))))
+              (for-each (lambda (file)
+                          (translate-tmp-texi po (string-append file ".texi")
+                                              (string-append file "." lang
+                                                             ".texi.tmp")))
+                        (cons prefix extras))
+
+              (for-each (lambda (file)
+                          (let* ((texi (string-append file "." lang ".texi"))
+                                 (tmp  (string-append texi ".tmp")))
+                            (with-output-to-file texi
+                              (lambda ()
+                                (display
+                                 (translate-cross-references
+                                  (call-with-input-file tmp get-string-all)
+                                  translations))))))
+                        (cons prefix extras))))
 
           (for-each (lambda (po)
                       (match (reverse (string-split po #\.))
                         ((_ lang _ ...)
-                         (translate-texi po lang))))
+                         (translate-texi "guix" po lang
+                                         #:extras '("contributing")))))
                     (find-files "." 
"^guix-manual\\.[a-z]{2}(_[A-Z]{2})?\\.po$"))
 
           (for-each



reply via email to

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