.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Locale::Po4a::TeX 3pm" .TH Locale::Po4a::TeX 3pm "2020-08-19" "Po4a Tools" "Po4a Tools" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Locale::Po4a::TeX \- convert TeX documents and derivates from/to PO files .SH "DESCRIPTION" .IX Header "DESCRIPTION" The po4a (\s-1PO\s0 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. .PP Locale::Po4a::TeX is a module to help the translation of TeX documents into other [human] languages. It can also be used as a base to build modules for TeX-based documents. .PP Users should probably use the LaTeX module, which inherits from the TeX module and contains the definitions of common LaTeX commands. .SH "TRANSLATING WITH PO4A::TEX" .IX Header "TRANSLATING WITH PO4A::TEX" This module can be used directly to handle generic TeX documents. This will split your document in smaller blocks (paragraphs, verbatim blocks, or even smaller like titles or indexes). .PP There are some options (described in the next section) that can customize this behavior. If this doesn't fit to your document format you're encouraged to write your own module derived from this, to describe your format's details. See the section \fB\s-1WRITING DERIVATE MODULES\s0\fR below, for the process description. .PP This module can also be customized by lines starting with \*(L"% po4a:\*(R" in the TeX file. These customizations are described in the \fB\s-1INLINE CUSTOMIZATION\s0\fR section. .SH "OPTIONS ACCEPTED BY THIS MODULE" .IX Header "OPTIONS ACCEPTED BY THIS MODULE" These are this module's particular options: .IP "\fBdebug\fR" 4 .IX Item "debug" Activate debugging for some internal mechanisms of this module. Use the source to see which parts can be debugged. .IP "\fBno_wrap\fR" 4 .IX Item "no_wrap" Comma-separated list of environments which should not be re-wrapped. .Sp Note that there is a difference between verbatim and no_wrap environments. There is no command and comments analysis in verbatim blocks. .Sp If this environment was not already registered, po4a will consider that this environment does not take any parameters. .IP "\fBexclude_include\fR" 4 .IX Item "exclude_include" Colon-separated list of files that should not be included by \einput and \&\einclude. .IP "\fBdefinitions\fR" 4 .IX Item "definitions" The name of a file containing definitions for po4a, as defined in the \&\fB\s-1INLINE CUSTOMIZATION\s0\fR section. You can use this option if it is not possible to put the definitions in the document being translated. .IP "\fBverbatim\fR" 4 .IX Item "verbatim" Comma-separated list of environments which should be taken as verbatim. .Sp If this environment was not already registered, po4a will consider that this environment does not take any parameters. .PP Using these options permits to override the behaviour of the commands defined in the default lists. .SH "INLINE CUSTOMIZATION" .IX Header "INLINE CUSTOMIZATION" The TeX module can be customized with lines starting by \fB% po4a:\fR. These lines are interpreted as commands to the parser. The following commands are recognized: .IP "\fB% po4a: command\fR \fIcommand1\fR \fBalias\fR \fIcommand2\fR" 4 .IX Item "% po4a: command command1 alias command2" Indicates that the arguments of the \fIcommand1\fR command should be treated as the arguments of the \fIcommand2\fR command. .IP "\fB% po4a: command\fR \fIcommand1\fR \fIparameters\fR" 4 .IX Item "% po4a: command command1 parameters" This permit to describe in detail the parameters of the \fIcommand1\fR command. This information will be used to check the number of arguments and their types. .Sp You can precede the \fIcommand1\fR command by .RS 4 .IP "an asterisk (\fB*\fR)" 4 .IX Item "an asterisk (*)" po4a will extract this command from paragraphs (if it is located at the beginning or the end of a paragraph). The translators will then have to translate the parameters that are marked as translatable. .IP "a plus (\fB+\fR)" 4 .IX Item "a plus (+)" As for an asterisk, the command will be extracted if it appear at an extremity of a block, but the parameters won't be translated separately. The translator will have to translate the command concatenated to all its parameters. This permits to keep more context, and is useful for commands with small words in parameter, which can have multiple meanings (and translations). .Sp Note: In this case you don't have to specify which parameters are translatable, but po4a must know the type and number of parameters. .IP "a minus (\fB\-\fR)" 4 .IX Item "a minus (-)" In this case, the command won't be extracted from any block. But if it appears alone on a block, then only the parameters marked as translatable will be presented to the translator. This is useful for font commands. These commands should generally not be separated from their paragraph (to keep the context), but there is no reason to annoy the translator with them if a whole string is enclosed in such a command. .RE .RS 4 .Sp The \fIparameters\fR argument is a set of [] (to indicate an optional argument) or {} (to indicate a mandatory argument). You can place an underscore (_) between these brackets to indicate that the parameter must be translated. For example: % po4a: command *chapter [_]{_} .Sp This indicates that the chapter command has two parameters: an optional (short title) and a mandatory one, which must both be translated. If you want to specify that the href command has two mandatory parameters, that you don't want to translate the \s-1URL\s0 (first parameter), and that you don't want this command to be separated from its paragraph (which allow the translator to move the link in the sentence), you can use: % po4a: command \-href {}{_} .Sp In this case, the information indicating which arguments must be translated is only used if a paragraph is only composed of this href command. .RE .IP "\fB% po4a: environment\fR \fIenv\fR \fIparameters\fR" 4 .IX Item "% po4a: environment env parameters" This permits to define the parameters accepted by the \fIenv\fR environment. This information is later used to check the number of arguments of the \&\ebegin command, and permit to specify which one must be translated. The syntax of the \fIparameters\fR argument is the same as described for the others commands. The first parameter of the \ebegin command is the name of the environment. This parameter must not be specified in the list of parameters. Here are some examples: % po4a: environment multicols {} % po4a: environment equation .Sp As for the commands, \fIenv\fR can be preceded by a plus (+) to indicate that the \ebegin command must be translated with all its arguments. .ie n .IP "\fB% po4a: separator\fR \fIenv\fR \fB""\fR\fIregex\fR\fB""\fR" 4 .el .IP "\fB% po4a: separator\fR \fIenv\fR \fB``\fR\fIregex\fR\fB''\fR" 4 .IX Item "% po4a: separator env ""regex""" Indicates that an environment should be split according to the given regular expression. .Sp The regular expression is delimited by quotes. It should not create any backreference. You should use (?:) if you need a group. It may also need some escapes. .Sp For example, the LaTeX module uses the \*(L"(?:&|\e\e\e\e)\*(R" regular expression to translate separately each cell of a table (lines are separated by '\e\e' and cells by '&'). .Sp The notion of environment is expended to the type displayed in the \s-1PO\s0 file. This can be used to split on \*(L"\e\e\e\e\*(R" in the first mandatory argument of the title command. In this case, the environment is title{#1}. .IP "\fB% po4a: verbatim environment\fR \fIenv\fR" 4 .IX Item "% po4a: verbatim environment env" Indicate that \fIenv\fR is a verbatim environment. Comments and commands will be ignored in this environment. .Sp If this environment was not already registered, po4a will consider that this environment does not take any parameters. .SH "WRITING DERIVATE MODULES" .IX Header "WRITING DERIVATE MODULES" .IP "\fBpre_trans\fR" 4 .IX Item "pre_trans" .PD 0 .IP "\fBpost_trans\fR" 4 .IX Item "post_trans" .IP "\fBadd_comment\fR" 4 .IX Item "add_comment" .PD Add a string as a comment to be added around the next translated element. This is mostly useful to the texinfo module, as comments are automatically handled in TeX. .IP "\fBtranslate\fR" 4 .IX Item "translate" Wrapper around Transtractor's translate, with pre\- and post-processing filters. .Sp Comments of a paragraph are inserted as a \s-1PO\s0 comment for the first translated string of this paragraph. .IP "\fBget_leading_command\fR($buffer)" 4 .IX Item "get_leading_command($buffer)" This function returns: .RS 4 .IP "A command name" 4 .IX Item "A command name" If no command is found at the beginning of the given buffer, this string will be empty. Only commands that can be separated are considered. The \f(CW%separated_command\fR hash contains the list of these commands. .IP "A variant" 4 .IX Item "A variant" This indicates if a variant is used. For example, an asterisk (*) can be added at the end of sections command to specify that they should not be numbered. In this case, this field will contain \*(L"*\*(R". If there is no variant, the field is an empty string. .IP "An array of tuples (type of argument, argument)" 4 .IX Item "An array of tuples (type of argument, argument)" The type of argument can be either '{' (for mandatory arguments) or '[' (for optional arguments). .IP "The remaining buffer" 4 .IX Item "The remaining buffer" The rest of the buffer after the removal of this leading command and its arguments. If no command is found, the original buffer is not touched and returned in this field. .RE .RS 4 .RE .IP "\fBget_trailing_command\fR($buffer)" 4 .IX Item "get_trailing_command($buffer)" The same as \fBget_leading_command\fR, but for commands at the end of a buffer. .IP "\fBtranslate_buffer\fR" 4 .IX Item "translate_buffer" Recursively translate a buffer by separating leading and trailing commands (those which should be translated separately) from the buffer. .Sp If a function is defined in \f(CW%translate_buffer_env\fR for the current environment, this function will be used to translate the buffer instead of \&\fBtranslate_buffer()\fR. .IP "\fBread\fR" 4 .IX Item "read" Overloads Transtractor's \fBread()\fR. .IP "\fBread_file\fR" 4 .IX Item "read_file" Recursively read a file, appending included files which are not listed in the \&\f(CW@exclude_include\fR array. Included files are searched using the \fBkpsewhich\fR command from the Kpathsea library. .Sp Except from the file inclusion part, it is a cut and paste from Transtractor's read. .IP "\fBparse_definition_file\fR" 4 .IX Item "parse_definition_file" Subroutine for parsing a file with po4a directives (definitions for new commands). .IP "\fBparse_definition_line\fR" 4 .IX Item "parse_definition_line" Parse a definition line of the form \*(L"% po4a: \*(R". .Sp See the \fB\s-1INLINE CUSTOMIZATION\s0\fR section for more details. .IP "\fBis_closed\fR" 4 .IX Item "is_closed" .PD 0 .IP "\fBparse\fR" 4 .IX Item "parse" .IP "\fBdocheader\fR" 4 .IX Item "docheader" .PD .SH "INTERNAL FUNCTIONS used to write derivated parsers" .IX Header "INTERNAL FUNCTIONS used to write derivated parsers" Command and environment functions take the following arguments (in addition to the \f(CW$self\fR object): .IP "A command name" 4 .IX Item "A command name" .PD 0 .IP "A variant" 4 .IX Item "A variant" .IP "An array of (type, argument) tuples" 4 .IX Item "An array of (type, argument) tuples" .IP "The current environment" 4 .IX Item "The current environment" .PD .PP The first 3 arguments are extracted by get_leading_command or get_trailing_command. .PP Command and environment functions return the translation of the command with its arguments and a new environment. .PP Environment functions are called when a \ebegin command is found. They are called with the \ebegin command and its arguments. .PP The TeX module only proposes one command function and one environment function: generic_command and generic_environment. .PP generic_command uses the information specified by register_generic_command or by adding definition to the TeX file: % po4a: command \fIcommand1\fR \fIparameters\fR .PP generic_environment uses the information specified by register_generic_environment or by adding definition to the TeX file: % po4a: environment \fIenv\fR \fIparameters\fR .PP Both functions will only translate the parameters that were specified as translatable (with a '_'). generic_environment will append the name of the environment to the environment stack and generic_command will append the name of the command followed by an identifier of the parameter (like {#7} or [#2]). .SH "STATUS OF THIS MODULE" .IX Header "STATUS OF THIS MODULE" This module needs more tests. .PP It was tested on a book and with the Python documentation. .SH "TODO LIST" .IX Header "TODO LIST" .IP "Automatic detection of new commands" 4 .IX Item "Automatic detection of new commands" The TeX module could parse the newcommand arguments and try to guess the number of arguments, their type and whether or not they should be translated. .IP "Translation of the environment separator" 4 .IX Item "Translation of the environment separator" When \eitem is used as an environment separator, the item argument is attached to the following string. .IP "Some commands should be added to the environment stack" 4 .IX Item "Some commands should be added to the environment stack" These commands should be specified by couples. This could allow to specify commands beginning or ending a verbatim environment. .IP "Others" 4 .IX Item "Others" Various other points are tagged \s-1TODO\s0 in the source. .SH "KNOWN BUGS" .IX Header "KNOWN BUGS" Various points are tagged \s-1FIXME\s0 in the source. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBLocale::Po4a::LaTeX\fR\|(3pm), \&\fBLocale::Po4a::TransTractor\fR\|(3pm), \&\fBpo4a\fR\|(7) .SH "AUTHORS" .IX Header "AUTHORS" .Vb 1 \& Nicolas François .Ve .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright © 2004, 2005 Nicolas FRANÇOIS . .PP This program is free software; you may redistribute it and/or modify it under the terms of \s-1GPL\s0 (see the \s-1COPYING\s0 file).