From 83ee4dcf87943167e15efff29c59fd92a28668b7 Mon Sep 17 00:00:00 2001 From: Florian Pelz Date: Sun, 2 Apr 2023 20:44:01 +0200 Subject: po: Do not auto-translate cross-references to other manuals. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported by Gottfried at . * guix/build/po.scm (xref-regexp): Dispatch on the number of arguments. Ensure there is no info-manual argument or it is empty. (translate-cross-references): Adapt to changed regexp. Signed-off-by: Ludovic Courtès --- guix/build/po.scm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'guix/build') diff --git a/guix/build/po.scm b/guix/build/po.scm index 7f88164cd8..62362e933e 100644 --- a/guix/build/po.scm +++ b/guix/build/po.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019, 2021 Julien Lepiller ;;; Copyright © 2020 Ludovic Courtès +;;; Copyright © 2023 Florian Pelz ;;; ;;; This file is part of GNU Guix. ;;; @@ -123,7 +124,15 @@ and the value is the msgstr. The result only contains non fuzzy strings." (define xref-regexp ;; Texinfo cross-reference regexp. - (make-regexp "@(px|x)?ref\\{([^,}]+)")) + (make-regexp + (string-append "@(px|x)?ref\\{([^,}]+)(" + "\\}" ;Match xref with one argument + "|,[^,}]*\\}" ;or two arguments + "|,[^,}]*,[^,}]*\\}" ;or three arguments + ;; or with an *empty* fourth argument: + "|,[^,}]*,[^,}]*, *," + "|,[^,}]*,[^,}]*, *\\}" + ")"))) (define (translate-cross-references texi pofile) "Translate the cross-references that appear in @var{texi}, the initial @@ -157,13 +166,15 @@ translation of a Texinfo file, using the msgid/msgstr pairs from @var{pofile}." (cons (string-drop content offset) result))) ((head . tail) (let ((prefix (match:substring head 1)) - (ref (canonicalize-whitespace (match:substring head 2)))) + (ref (canonicalize-whitespace (match:substring head 2))) + (rest (match:substring head 3))) (define translated (string-append "@" (or prefix "") "ref{" (match (vhash-assoc ref translation-map) (#f ref) - ((_ . str) str)))) + ((_ . str) str)) + (or rest ""))) (loop tail (match:end head) -- cgit v1.2.3