mquinson / po4a

Maintain the translations of your documentation with ease (PO for anything)
http://po4a.org/
GNU General Public License v2.0
127 stars 62 forks source link

Adding PO file headers to translated documents #73

Open mquinson opened 6 years ago

mquinson commented 6 years ago

First reported on Alioth on 27/09/2004 by me:

the po-debiandoc tool writes the PO-file header in the generated
SGML file (enclosed in <!-- ... -->, of course), so that these
useful informations are contained in this file.
It would be really nice if po4a-translate did something similar.

(Reported by Denis on the mailing list)
mquinson commented 6 years ago

Fixing this requires a collaboration between the TransTractor and each module: the TransTractor knows the po header content, and the modules know how to mark a given content as a comment in the translated file.

First, you need to add a headerpo() function to the TransTractor so that each module can retrieve this info. The TransTractor should naturally ask this info to its input po file (retrieved with $_[0]->{TT}{po_in}), but the Po.pm module does not export it so far. So you need to add a header() function to Po.pm to return $self->{header_comment}."\n".$self->{header}. I advise here to return the concatenation of header comment and actual header because we want both info as a comment in the translated document, I guess. Actually implementing the stuff may show that I'm wrong, that we don't need both. If so, adapt from my advise.

Once headerpo() is implemented, you need to modify each module to make use of it. For example in Sgml.pm, you need to do something like $self->pushline("<!--".$self->headerpo()."-->");

Feel free to solve this issue with several PRs: for example one for the TransTractor::headerpo() method and one per updated module. A good PR is submitted. A better PR is merged. A full and perfect PR is neither of them :)