Locale::Po4a::Man(3pm) | Po4a Tools | Locale::Po4a::Man(3pm) |
Locale::Po4a::Man - convert manual pages from/to PO files
The po4a (PO for anything) project goal is to ease translations (and more interestingly, the maintenance of translations) using gettext tools on areas where they were not expected like documentation.
Locale::Po4a::Man is a module to help the translation of documentation in the nroff format (the language of manual pages) into other [human] languages.
This module tries pretty hard to make translator's life easier. For that, the text presented to translators isn't a verbatim copy of the text found in the man page. Indeed, the cruder parts of the nroff format are hidden, so that translators can't mess up with them.
Unindented paragraphs are automatically rewrapped for the translator. This can lead to some minor difference in the generated output, since the rewrapping rules used by groff aren't very clear. For example, two spaces after a parenthesis are sometimes preserved.
Anyway, the difference will only be about the position of the extra spaces in wrapped paragraph, and I think it's worth.
The first change is about font change specifications. In nroff, there are several ways to specify if a given word should be written in small, bold or italics. In the text to translate, there is only one way, borrowed from the POD (Perl online documentation) format:
Remark: The CW face is not available for all groff devices. It is not recommended to use it. It is provided for your convenience.
Po4a automatically transliterate some characters to ease the translation or the review of the translation. Here is the list of the transliterations:
Translators can force an hyphen by using the roff glyph '\[hy]' in their translations.
To avoid these transliterations, translators can insert a zero width roff character (i.e., using `\&` or '\&' respectively).
Since these chars are used to delimit parts under font modification, you can't use them verbatim. Use E<lt> and E<gt> instead (as in POD, one more time).
These are this module's particular options:
It selects a stricter support of the mdoc format by telling po4a not to translate the 'NAME' section. mdoc pages whose 'NAME' section is translated won't generate any header or footer.
According to the groff_mdoc page, the NAME, SYNOPSIS and
DESCRIPTION sections are mandatory. There are no known issues with
translated SYNOPSIS or DESCRIPTION section, but you can also specify
these sections this way:
-o mdoc=NAME,SYNOPSIS,DESCRIPTION
This mdoc issue can also be solved with an addendum like this
one:
PO4A-HEADER:mode=before;position=^.Dd
.TH DOCUMENT_TITLE 1 "Month day, year" OS "Section
Name"
The following options permit to specify the behavior of a new macro (defined with a .de request), or of a macro not supported by po4a. They take as argument a comma-separated list of macros. For example:
-o noarg=FO,OB,AR -o translate_joined=BA,ZQ,UX
Note: if a macro is not supported by po4a and if you consider that it is a standard roff macro, you should submit it to the po4a development team.
Note: no test is done to ensure that an end command matches its begin command; any ending command stop the no_wrap mode. If you have a begin (respectively end) macro that has no end (respectively begin), you can specify an existing end (like fi) or begin (like nf) as a counterpart. These macros (and their arguments) wont be translated.
This module is still very limited, and will always be, because it's not a real nroff interpreter. It would be possible to do a real nroff interpreter, to allow authors to use all the existing macros, or even to define new ones in their pages, but we didn't want to. It would be too difficult, and we thought it wasn't necessary. We do think that if manpages' authors want to see their productions translated, they may have to adapt to ease the work of translators.
So, the man parser implemented in po4a have some known limitations we are not really inclined to correct, and which will constitute some pitfalls you'll have to avoid if you want to see translators taking care of your documentation.
nroff is a complete programming language, with macro definition, conditionals and so on. Since this parser isn't a fully featured nroff interpreter, it will fail on pages using these facilities (There are about 200 such pages on my box).
There are still some macros which are not supported by po4a::man. This is only because I failed to find any documentation about them. Here is the list of unsupported macros used on my box. Note that this list isn't exhaustive since the program fails on the first encountered unsupported macro. If you have any information about some of these macros, I'll happily add support for them. Because of these macros, about 250 pages on my box are inaccessible to po4a::man.
.. ." .AT .b .bank .BE ..br .Bu .BUGS .BY .ce .dbmmanage .do .En .EP .EX .Fi .hw .i .Id .l .LO .mf .N .na .NF .nh .nl .Nm .ns .NXR .OPTIONS .PB .pp .PR .PRE .PU .REq .RH .rn .S< .sh .SI .splitfont .Sx .T .TF .The .TT .UC .ul .Vb .zZ
Sometimes, the author knows that some parts are not translatable, and should not be extracted by po4a. For example, an option may accept an other argument, and other may also appear as the last item of a list. In the first case, other should be not be translatable. And in the second case, other should be translated.
In such case, the author can avoid po4a to extract some strings, using some special groff constructs:
.if !'po4a'hide' .B other
(this will require the -o groff_code=verbatim option)
A new macro can also be defined to automate this:
.de IR_untranslated
. IR \\$@
..
.IR_untranslated \-q ", " \-\-quiet
(this will require the options -o groff_code=verbatim and -o untranslated=IR_untranslated; with this construct, the .if !'po4a'hide' conditional is not strictly needed since po4a will not parse the internal of the macro definition)
or using an alias:
.als IR_untranslated IR
.IR_untranslated \-q ", " \-\-quiet
This will require the -o untranslated=als,IR_untranslated option.
To summarise this section, keep simple, and don't try to be clever while authoring your man pages. A lot of things are possible in nroff, and not supported by this parser. For example, don't try to mess with \c to interrupt the text processing (like 40 pages on my box do). Or, be sure to put the macro arguments on the same line that the macro itself. I know that it's valid in nroff, but would complicate too much the parser to be handled.
Of course, another possibility is to use another format, more translator friendly (like POD using po4a::pod, or one of the XML family like SGML), but thanks to po4a::man it isn't needed anymore. That being said, if the source format of your documentation is POD, or XML, it may be clever to translate the source format and not this generated one. In most cases, po4a::man will detect generated pages and issue a warning. It will even refuse to process POD generated pages, because those pages are perfectly handled by po4a::pod, and because their nroff counterpart defines a lot of new macros I didn't want to write support for. On my box, 1432 of the 4323 pages are generated from POD and will be ignored by po4a::man.
In most cases, po4a::man will detect the problem and refuse to process the page, issuing an adapted message. In some rare cases, the program will complete without warning, but the output will be wrong. Such cases are called "bugs" ;) If you encounter such case, be sure to report this, along with a fix when possible…
This module can be used for most of the existing man pages.
Some tests are regularly run on Linux boxes:
Locale::Po4a::Pod(3pm), Locale::Po4a::TransTractor(3pm), po4a(7)
Denis Barbier <barbier@linuxfr.org> Nicolas François <nicolas.francois@centraliens.net> Martin Quinson (mquinson#debian.org)
Copyright © 2002-2008 SPI, Inc.
This program is free software; you may redistribute it and/or modify it under the terms of GPL (see the COPYING file).
2020-12-09 | Po4a Tools |