unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Maxime Devos <maximedevos@telenet.be>
Cc: 46872@debbugs.gnu.org
Subject: [bug#46872] [PATCH] doc: Define canned recipes for creating translated manuals.
Date: Thu, 20 Jan 2022 15:05:12 +0100	[thread overview]
Message-ID: <874k5y8puv.fsf@gnu.org> (raw)
In-Reply-To: <d26260fe4874eceb3956fbb81a69ebdaf1d41f2a.camel@telenet.be> (Maxime Devos's message of "Tue, 02 Mar 2021 14:40:20 +0100")

[-- Attachment #1: Type: text/plain, Size: 1753 bytes --]

Hi Maxime,

Maxime Devos <maximedevos@telenet.be> skribis:

> From 140504026807af6d4e94154b629edb6c7bdf3c27 Mon Sep 17 00:00:00 2001
> From: Maxime Devos <maximedevos@telenet.be>
> Date: Tue, 2 Mar 2021 14:13:59 +0100
> Subject: [PATCH] doc: Define canned recipes for creating translated manuals.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> It is expected that at some point in the future, the manual's
> source will be split in several files per-chapter.  Prevent
> the build recipes from diverging by defining and using two
> ‘canned recipes’ in the makefile for translating the manual
> and individual chapters.
>
> * doc/local.mk
>   (guix.%.texi, guix-cookbook.%.texi): move recipe ...
>   (translate_manual_command): ... to here.
>   (contributing.%.texi): move recipe ...
>   (translate_chapter_command): ... to here.

This had fallen through the cracks.

I updated it so it applies on current master (see below).  However, it
doesn’t work as expected:

--8<---------------cut here---------------start------------->8---
$ rm -f doc/contributing.fr.texi
$ make doc/contributing.fr.texi
make: 'doc/contributing.fr.texi' is up to date.
$ ls -l doc/contributing.fr.texi
ls: ne eblas atingi 'doc/contributing.fr.texi': Dosiero aŭ dosierujo ne ekzistas
--8<---------------cut here---------------end--------------->8---

If I inline the expansion of ‘translate_chapter_command’, everything
works as expected.

My GNU Make is rusty and fuzzy, but I wonder if we can expand text that
includes tabs.  I vaguely remember that I’d usually define functions
that would expand the whole text: target/prerequisites + commands.

WDYT?

Ludo’.


[-- Attachment #2: Type: text/x-patch, Size: 2550 bytes --]

diff --git a/doc/local.mk b/doc/local.mk
index 9619971296..627d27a5ef 100644
--- a/doc/local.mk
+++ b/doc/local.mk
@@ -5,6 +5,7 @@
 # Copyright © 2016 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
 # Copyright © 2016, 2018 Mathieu Lirzin <mthl@gnu.org>
 # Copyright © 2018, 2021 Julien Lepiller <julien@lepiller.eu>
+# Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 #
 # This file is part of GNU Guix.
 #
@@ -111,22 +112,33 @@ $(top_srcdir)/pre-inst-env $(GUILE) --no-auto-compile	\
   $@.tmp $<
 endef
 
+# This canned recipe is used in the rules below to translate a Texinfo manual
+# using the translations in po/doc.  The argument $(1) is the name of the
+# untranslated manual, without a .texi extension or directory prefixes.
+define translate_manual_command
+	-$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/$(1).texi" -p "$<" -l "$@.tmp"
+	-sed -i "s|$(1)\.info|$$(basename "$@" | sed 's|texi$$|info|')|" "$@.tmp"
+	-$(AM_V_POXREF)LC_ALL=en_US.UTF-8 $(xref_command)
+	-mv "$@.tmp" "$@"
+endef
+
+# Likewise, but for individual chapters (or sections), which do not have an
+# Info file name to modify.
+define translate_chapter_command
+	-$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/$(1).texi" -p "$<" -l "$@.tmp"
+	-$(AM_V_POXREF)LC_ALL=en_US.UTF-8 $(xref_command)
+	-mv "$@.tmp" "$@"
+endef
+
+
 $(srcdir)/%D%/guix.%.texi: po/doc/guix-manual.%.po $(srcdir)/%D%/contributing.%.texi guix/build/po.go
-	-$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/guix.texi" -p "$<" -l "$@.tmp"
-	-sed -i "s|guix\.info|$$(basename "$@" | sed 's|texi$$|info|')|" "$@.tmp"
-	-$(AM_V_POXREF)LC_ALL=en_US.UTF-8 $(xref_command)
-	-mv "$@.tmp" "$@"
+	$(call translate_manual_command,guix)
 
 $(srcdir)/%D%/guix-cookbook.%.texi: po/doc/guix-cookbook.%.po guix/build/po.go
-	-$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/guix-cookbook.texi" -p "$<" -l "$@.tmp"
-	-sed -i "s|guix-cookbook\.info|$$(basename "$@" | sed 's|texi$$|info|')|" "$@.tmp"
-	-$(AM_V_POXREF)LC_ALL=en_US.UTF-8 $(xref_command)
-	-mv "$@.tmp" "$@"
+	$(call translate_manual_command,guix-cookbook)
 
 $(srcdir)/%D%/contributing.%.texi: po/doc/guix-manual.%.po guix/build/po.go
-	-$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/contributing.texi" -p "$<" -l "$@.tmp"
-	-$(AM_V_POXREF)LC_ALL=en_US.UTF-8 $(xref_command)
-	-mv "$@.tmp" "$@"
+	$(call translate_manual_chapter,contributing)
 
 %D%/os-config-%.texi: gnu/system/examples/%.tmpl
 	$(AM_V_GEN)$(MKDIR_P) "`dirname $@`";	\

  reply	other threads:[~2022-01-20 20:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 13:40 [bug#46872] [PATCH] doc: Define canned recipes for creating translated manuals Maxime Devos
2022-01-20 14:05 ` Ludovic Courtès [this message]
2022-01-20 16:44   ` Maxime Devos

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=874k5y8puv.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=46872@debbugs.gnu.org \
    --cc=maximedevos@telenet.be \
    /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).