Subject: Some manual @ref @xref @pxref fail when untranslated

From: "pelzflorian (Florian Pelz)" <[email-masked]>
Date: Sat, 18 May 2019 00:48:26 +0200

Meiyo Peng reports at <https://lists.gnu.org/archive/html/guix-devel/2019-05/msg00275.html>

On Tue, May 14, 2019 at 10:29:35AM +0800, Meiyo Peng wrote:
> I just find out that the @pxref{Packages with Multiple Outputs} in
> doc/contributing.texi has to be translated.  Or I will get an error
> while running make:
> 
> #+begin_example
>   doc/contributing.zh_CN.texi:567: @pxref reference to nonexistent node `Packages with Multiple Outputs'
> #+end_example
> 
> I guess it's because the node name is in doc/guix.texi (another file
> than doc/contributing.texi).  Any idea?
> 

The reason appears to be that when not translating (using the first
attached patch that reverts back to @pxref{Packages with Multiple
Outputs}), po4a-translate transforms

@item
Take a look at the profile reported by @command{guix size}
(@pxref{Invoking guix size}).  This will allow you to notice references
to other packages unwillingly retained.  It may also help determine
whether to split the package (@pxref{Packages with Multiple Outputs}),
and which optional dependencies should be used.  In particular, avoid adding
@code{texlive} as a dependency: because of its extreme size, use
@code{texlive-tiny} or @code{texlive-union} instead.

to

@item
看一下@command{guix size}（@pxref{Invoking guix
size}）的分析报告。这会让你注意到对其它软件包无意中的引用。它也可以帮助决定是否要把一个软件包分割成几个输出（@pxref{Packages
with Multiple
Outputs}），以及需要使用哪些可选的依赖。特别地，避免把@code{texlive}添加为依赖：因为它太大了，请使用@code{texlive-tiny}或@code{texlive-union}代替它。

with the pxref split over three lines because the surrounding context
has no space characters.  doc/local.mk’s xref_command can only deal
with two lines however.

The second attached patch makes xref_command grep three-line
references too, so it finds the translation, *however* I cannot get
this multiline sed to actually insert the translation into three line
references.  Perhaps it would be better to just replace this complex
xref_command with Guile code?  I will not do it however.

I am Cc’ing the [email-masked]; I hope this is OK.

Regards,
Florian

>From 267cc4c506d03ad35bfeead0f45d77bc7d242181 Mon Sep 17 00:00:00 2001
From: Florian Pelz <[email-masked]>
Date: Sat, 18 May 2019 00:29:21 +0200
Subject: [PATCH 1/2] THIS IS A TEST: Revert to not translating pxref
 reference.

---
 po/doc/guix-manual.zh_CN.po | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/po/doc/guix-manual.zh_CN.po b/po/doc/guix-manual.zh_CN.po
index c24900da31..d1351ef557 100644
--- a/po/doc/guix-manual.zh_CN.po
+++ b/po/doc/guix-manual.zh_CN.po
@@ -8,7 +8,7 @@ msgstr ""
 "Project-Id-Version: guix-manual 1.0.1-pre1\n"
 "Report-Msgid-Bugs-To: [email-masked]\n"
 "POT-Creation-Date: 2019-05-10 20:53+0200\n"
-"PO-Revision-Date: 2019-05-14 14:31+0800\n"
+"PO-Revision-Date: 2019-05-17 17:21+0200\n"
 "Last-Translator: Meiyo Peng <[email-masked]>\n"
 "Language-Team: Chinese (simplified) <[email-masked]>\n"
 "Language: zh_CN\n"
@@ -1237,7 +1237,7 @@ msgstr "有时，软件包为了方便用户，捆绑了依赖库的源代码。
 #. type: enumerate
 #: doc/contributing.texi:868
 msgid "Take a look at the profile reported by @command{guix size} (@pxref{Invoking guix size}).  This will allow you to notice references to other packages unwillingly retained.  It may also help determine whether to split the package (@pxref{Packages with Multiple Outputs}), and which optional dependencies should be used.  In particular, avoid adding @code{texlive} as a dependency: because of its extreme size, use @code{texlive-tiny} or @code{texlive-union} instead."
-msgstr "看一下@command{guix size}（@pxref{Invoking guix size}）的分析报告。这会让你注意到对其它软件包无意中的引用。它也可以帮助决定是否要把一个软件包分割成几个输出（@pxref{有多个输出的软件包}），以及需要使用哪些可选的依赖。特别地，避免把@code{texlive}添加为依赖：因为它太大了，请使用@code{texlive-tiny}或@code{texlive-union}代替它。"
+msgstr "看一下@command{guix size}（@pxref{Invoking guix size}）的分析报告。这会让你注意到对其它软件包无意中的引用。它也可以帮助决定是否要把一个软件包分割成几个输出（@pxref{Packages with Multiple Outputs}），以及需要使用哪些可选的依赖。特别地，避免把@code{texlive}添加为依赖：因为它太大了，请使用@code{texlive-tiny}或@code{texlive-union}代替它。"
 
 #. type: enumerate
 #: doc/contributing.texi:873
-- 
2.21.0

>From f9c3aae82c940238e6162e16cef0431ce782f5f3 Mon Sep 17 00:00:00 2001
From: Florian Pelz <[email-masked]>
Date: Sat, 18 May 2019 00:31:06 +0200
Subject: [PATCH 2/2] doc: Insufficient attempt to fix translation of
 three-line references.

* doc/local.mk (xref_command): Catch three-line translations as well, but the
multiline sed still covers only two lines.
---
 doc/local.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/local.mk b/doc/local.mk
index 336e961c4f..645e571817 100644
--- a/doc/local.mk
+++ b/doc/local.mk
@@ -88,7 +88,7 @@ PO4A_PARAMS += -f texinfo # texinfo format
 # reference name, even in untranslated strings.
 # The last sed is a multiline sed because some references span multiple lines.
 define xref_command
-cat "$@.tmp" | egrep '@p?x?ref' -A1 | sed 'N;s|--\n||g;P;D' | sed 's|^| |g' | \
+cat "$@.tmp" | egrep '@p?x?ref' -A2 | sed 'N;s|--\n||g;P;D' | sed 's|^| |g' | \
         tr -d '\012' | sed 's|\(@p\?x\?ref\)|\n\1|g' | egrep '@p?x?ref' | \
         sed 's|^.*@p\?x\?ref{\([^,}]*\).*$$|\1|g' | sort | uniq | while read e; do \
   line=$$(grep -n "^msgid \"$$e\"" "$<" | cut -f1 --delimiter=":") ;\
-- 
2.21.0