me
/
guix
Archived
1
0
Fork 0

po: Do not auto-translate cross-references to other manuals.

Reported by Gottfried at
<https://lists.gnu.org/archive/html/help-guix/2023-04/msg00000.html>.

* 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 <ludo@gnu.org>
master
Florian Pelz 2023-04-02 20:44:01 +02:00 committed by Ludovic Courtès
parent 09896b2913
commit 89c536775d
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 14 additions and 3 deletions

View File

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019, 2021 Julien Lepiller <julien@lepiller.eu> ;;; Copyright © 2019, 2021 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2023 Florian Pelz <pelzflorian@pelzflorian.de>
;;; ;;;
;;; This file is part of GNU Guix. ;;; 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 (define xref-regexp
;; Texinfo cross-reference 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) (define (translate-cross-references texi pofile)
"Translate the cross-references that appear in @var{texi}, the initial "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))) (cons (string-drop content offset) result)))
((head . tail) ((head . tail)
(let ((prefix (match:substring head 1)) (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 (define translated
(string-append "@" (or prefix "") (string-append "@" (or prefix "")
"ref{" "ref{"
(match (vhash-assoc ref translation-map) (match (vhash-assoc ref translation-map)
(#f ref) (#f ref)
((_ . str) str)))) ((_ . str) str))
(or rest "")))
(loop tail (loop tail
(match:end head) (match:end head)