From: "Ludovic Courtès" <ludo@gnu.org>
To: "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de>
Cc: 72257@debbugs.gnu.org, Julien Lepiller <julien@lepiller.eu>
Subject: bug#72257: Non-English manuals for 1.4.0 are unavailable
Date: Fri, 26 Jul 2024 00:32:41 +0200 [thread overview]
Message-ID: <87r0bhcdbq.fsf@gnu.org> (raw)
In-Reply-To: <877cdbaur6.fsf@pelzflorian.de> (pelzflorian@pelzflorian.de's message of "Wed, 24 Jul 2024 13:34:37 +0200")
[-- Attachment #1: Type: text/plain, Size: 1083 bytes --]
Hello,
"pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis:
> "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> writes:
>> The old manual as referred to in maintenance.git in
>> hydra/modules/sysadmin/web.scm was expected to build with the
>> guix/self.scm of old guix.git; it should not try to use po4a.cfg.
>
> The issue seems to be, maintenance.git in hydra/modules/sysadmin/web.scm
> uses old guix 1.4.0’s doc/build.scm, but it imports the (guix self)
> module by @@ from the new guix, which expects po4a.cfg.
>
> Can we make it @@ the modules from old guix 1.4.0?
Alternatively, could we use (@ (guix self) translate-texi-manuals) as it
existed in Guix commit 5f86eebd240958001ab4f178005f355d24d9b7f1 by
simply copying it to ‘doc/build.scm’ on the ‘version-1.4.0’ branch?
That seems simpler and more orthogonal to me than special-casing
(sysadmin web).
Patch below.
WDYT?
Ludo’.
PS: I’ll be away from keyboard in the coming days so feel free to push
to ‘version-1.4.0’ if it looks good to you.
[-- Attachment #2: Type: text/x-patch, Size: 5922 bytes --]
diff --git a/doc/build.scm b/doc/build.scm
index 0a5bddbcb6..345909bd57 100644
--- a/doc/build.scm
+++ b/doc/build.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2019-2023 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2019-2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
@@ -34,6 +34,7 @@
(guix profiles)
(guix utils)
(git)
+ (gnu packages)
(gnu packages base)
(gnu packages compression)
(gnu packages gawk)
@@ -52,8 +53,116 @@
(define file-append*
(@@ (guix self) file-append*))
-(define translated-texi-manuals
- (@@ (guix self) translate-texi-manuals))
+(define (translated-texi-manuals source)
+ "Return the translated texinfo manuals built from SOURCE."
+ (define po4a
+ (specification->package "po4a"))
+
+ (define gettext-minimal
+ (specification->package "gettext-minimal"))
+
+ (define documentation
+ (file-append* source "doc"))
+
+ (define documentation-po
+ (file-append* source "po/doc"))
+
+ (define build
+ (with-imported-modules '((guix build utils) (guix build po))
+ #~(begin
+ (use-modules (guix build utils) (guix build po)
+ (ice-9 match) (ice-9 regex) (ice-9 textual-ports)
+ (ice-9 vlist) (ice-9 threads)
+ (srfi srfi-1))
+
+ (define (translate-tmp-texi po source output)
+ "Translate Texinfo file SOURCE using messages from PO, and write
+the result to OUTPUT."
+ (invoke #+(file-append po4a "/bin/po4a-translate")
+ "-M" "UTF-8" "-L" "UTF-8" "-k" "0" "-f" "texinfo"
+ "-m" source "-p" po "-l" output))
+
+ (define (canonicalize-whitespace str)
+ ;; Change whitespace (newlines, etc.) in STR to #\space.
+ (string-map (lambda (chr)
+ (if (char-set-contains? char-set:whitespace chr)
+ #\space
+ chr))
+ str))
+
+ (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\")."
+ (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")))
+ (copy-file tmp texi)
+ (translate-cross-references texi po)))
+ (cons prefix extras)))
+
+ (define (available-translations directory domain)
+ ;; Return the list of available translations under DIRECTORY for
+ ;; DOMAIN, a gettext domain such as "guix-manual". The result is
+ ;; a list of language/PO file pairs.
+ (filter-map (lambda (po)
+ (let ((base (basename po)))
+ (and (string-prefix? (string-append domain ".")
+ base)
+ (match (string-split base #\.)
+ ((_ ... lang "po")
+ (cons lang po))))))
+ (find-files directory
+ "\\.[a-z]{2}(_[A-Z]{2})?\\.po$")))
+
+ (define parallel-jobs
+ ;; Limit thread creation by 'n-par-for-each', mostly to put an
+ ;; upper bound on memory usage.
+ (min (parallel-job-count) 4))
+
+ (mkdir #$output)
+ (copy-recursively #$documentation "."
+ #:log (%make-void-port "w"))
+
+ (for-each
+ (lambda (file)
+ (copy-file file (basename file)))
+ (find-files #$documentation-po ".*.po$"))
+
+ (setenv "GUIX_LOCPATH"
+ #+(file-append glibc-utf8-locales "/lib/locale"))
+ (setenv "PATH" #+(file-append gettext-minimal "/bin"))
+ (setenv "LC_ALL" "en_US.UTF-8")
+ (setlocale LC_ALL "en_US.UTF-8")
+
+ (n-par-for-each parallel-jobs
+ (match-lambda
+ ((language . po)
+ (translate-texi "guix" po language
+ #:extras '("contributing"))))
+ (available-translations "." "guix-manual"))
+
+ (n-par-for-each parallel-jobs
+ (match-lambda
+ ((language . po)
+ (translate-texi "guix-cookbook" po language)))
+ (available-translations "." "guix-cookbook"))
+
+ (for-each (lambda (file)
+ (install-file file #$output))
+ (append
+ (find-files "." "contributing\\..*\\.texi$")
+ (find-files "." "guix\\..*\\.texi$")
+ (find-files "." "guix-cookbook\\..*\\.texi$"))))))
+
+ (computed-file "guix-translated-texinfo" build))
(define info-manual
(@@ (guix self) info-manual))
next prev parent reply other threads:[~2024-07-25 22:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 14:36 bug#72257: Non-English manuals for 1.4.0 are unavailable Ludovic Courtès
2024-07-23 15:18 ` Ludovic Courtès
2024-07-23 19:59 ` Maxim Cournoyer
2024-07-24 10:04 ` pelzflorian (Florian Pelz)
2024-07-24 11:34 ` pelzflorian (Florian Pelz)
2024-07-24 15:58 ` pelzflorian (Florian Pelz)
2024-07-25 12:41 ` pelzflorian (Florian Pelz)
2024-07-25 22:32 ` Ludovic Courtès [this message]
2024-07-27 8:34 ` pelzflorian (Florian Pelz)
2024-07-28 7:35 ` pelzflorian (Florian Pelz)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r0bhcdbq.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=72257@debbugs.gnu.org \
--cc=julien@lepiller.eu \
--cc=pelzflorian@pelzflorian.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).