#1008064 po4a: HTML links with dash get stray backslash

Package:
po4a
Source:
po4a
Submitter:
Petter Reinholdtsen
Date:
2022-03-21 18:00:04 UTC
Severity:
normal
#1008064#5
Date:
2022-03-21 17:57:51 UTC
From:
To:
I ran into this problem while converting linuxcnc to use po4a to handle
translated documentation.

The problem is that working links in the English original is replaced
with broken links in the translated files, even though the original
English text is used because the translated string is missing.

The following script demonstrate the problem.

====================  test-po4a-html-links =======================
#!/bin/sh

cat << EOF > po4a.cfg
[po4a_langs] es
[po4a_paths] documentation.pot $lang:documentation_$lang.po
[po4a_alias:xhtml_def] man opt:"--keep 0"
[type: xhtml_def] gcode.html $lang:gcode_$lang.html
EOF

cat << EOF > gcode.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<BODY>
<TABLE ID=ref1>
<TR><TD><A HREF="g-code.html#gcode:g0">G0</A><TD><TD>Rapid Move</TR>
</TABLE>
</BODY>
EOF

cat << EOF > g-code.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<BODY>
<h1 id="#gcode:g0">G0</h1>
G0 described.
</BODY>
EOF

po4a po4a.cfg

grep HREF gcode.html
grep HREF gcode_es.html
==================================================================

This is the output I get:

% sh test-po4a-html-links
 (1 entries)
Error: 'msginit -i /scratch/pere/src/linuxcnc/po4a-fail/documentation.pot --locale  -o
/scratch/pere/src/linuxcnc/po4a-fail/documentation_.po --no-translator >/dev/null' exited
with value 1.
<TR><TD><A HREF="g-code.html#gcode:g0">G0</A><TD><TD>Rapid Move</TR>
<TR><TD><A HREF="g\-code.html#gcode:g0">G0</A><TD><TD>Rapid Move</TR>
%

Note how "g-code.html" become "g\-code.html" in the translated file,
thus breaking the link.  I expected both to use "g-code.html".