[Po4a-devel] Bug: reliance on empty lines

Moritz Bunkus moritz at bunkus.org
Sat Feb 28 09:36:51 UTC 2015


Hey,

before I come across as being negative I would like to thank you for
this nice project. I generally love it and am grateful for it.

Now on to the problem I've stumbled across yesterday.

Due to one of my scripts running amok I recently found out the hard way
that po4a-translate relies on the presence of empty lines in exactly the
right places. This is worrisome for two reasons: 1) it doesn't match the
behavior of the msg* utilities and 2) it introduces the potential for
subtle and hard-to-find problems. I also care about 3) po4a-translate
exiting with 0 even if it had to discard the translation making it
harder to detect such issues during build processes.

From my analysis each empty line is used as a separator between
entries. So for a file lacking any empty line none of the lines will
appear to be translated to po4a-translate. Observe (starting out with a
good file):

[0 mosu at sweet-chili (master) ~/prog/video/mkvtoolnix] /usr/bin/vendor_perl/po4a-translate -v -v -M utf-8 -k 1 -f docbook -m doc/man/mkvmerge.xml -p doc/man/po4a/po/nl.po -l /dev/null doc/man/mkvmerge.xml is 95.17% translated (533 of 560 strings).
[0 mosu at sweet-chili (master) ~/prog/video/mkvtoolnix] sed -i -e '/^$/d' doc/man/po4a/po/nl.po
[0 mosu at sweet-chili (master) ~/prog/video/mkvtoolnix] /usr/bin/vendor_perl/po4a-translate -v -v -M utf-8 -k 1 -f docbook -m doc/man/mkvmerge.xml -p doc/man/po4a/po/nl.po -l /dev/null Discard the translation of doc/man/mkvmerge.xml (only 0% translated; need 1%).

However, msg* doesn't care. This is still run with the bad file produced
above(I've stripped the output down to just nl.po and mkvmerge.xml for
brevity):

[0 mosu at sweet-chili (master) ~/prog/video/mkvtoolnix] po4a -d -M utf-8 -k 1  --msgmerge-opt=--no-wrap doc/man/po4a/po4a.cfg
cmd=[po4a_paths]; main=doc/man/po4a/po/mkvtoolnix.pot; args="nl:doc/man/po4a/po/nl.po"
cmd=[type: docbook]; main=doc/man/mkvmerge.xml; args="$lang:doc/man/$lang/mkvmerge.xml"
Updating doc/man/po4a/po/nl.po:
msgmerge -U doc/man/po4a/po/nl.po doc/man/po4a/po/mkvtoolnix.pot --no-wrap --previous --backup=none
........................................................................................................................... done.
doc/man/po4a/po/nl.po: 776 translated messages, 27 fuzzy translations, 31 untranslated messages.

Now, removing all blank lines is certainly one of the more extreme
issues. However, even with this done the problem remained undetected for
ten months including seven releases of my software, also because
po4a-translate exits with 0 even if it discards the translation.

The problem I'm more worried about, though, is 2) the potential for
subtle bugs. Using a normal text editor it's easy to remove such an
empty line accidentally. It's also easy to botch up some merge during
development. Or for some script to run amok.

So please fix the reliance on empty lines and implement proper
msgid/msgstr parsing.

Also please consider changing the exit code to anything but 0 if
po4a-translate has to discard the translation with -k …. It would make
integration into any build process more reliable.

Thanks.

Kind regards,
mosu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/po4a-devel/attachments/20150228/81fbc8c0/attachment.sig>


More information about the Po4a-devel mailing list