1Locale::Po4a::TeX(3pm)            Po4a Tools            Locale::Po4a::TeX(3pm)
2
3
4

NAME

6       Locale::Po4a::TeX - convert TeX documents and derivates from/to PO
7       files
8

DESCRIPTION

10       The po4a (PO for anything) project goal is to ease translations (and
11       more interestingly, the maintenance of translations) using gettext
12       tools on areas where they were not expected like documentation.
13
14       Locale::Po4a::TeX is a module to help the translation of TeX documents
15       into other [human] languages. It can also be used as a base to build
16       modules for TeX-based documents.
17
18       Users should probably use the LaTeX module, which inherits from the TeX
19       module and contains the definitions of common LaTeX commands.
20

TRANSLATING WITH PO4A::TEX

22       This module can be used directly to handle generic TeX documents.  This
23       will split your document in smaller blocks (paragraphs, verbatim
24       blocks, or even smaller like titles or indexes).
25
26       There are some options (described in the next section) that can
27       customize this behavior.  If this doesn't fit to your document format
28       you're encouraged to write your own module derived from this, to
29       describe your format's details.  See the section WRITING DERIVATE
30       MODULES below, for the process description.
31
32       This module can also be customized by lines starting with "% po4a:" in
33       the TeX file.  These customizations are described in the INLINE
34       CUSTOMIZATION section.
35

OPTIONS ACCEPTED BY THIS MODULE

37       These are this module's particular options:
38
39       debug
40           Activate debugging for some internal mechanisms of this module.
41           Use the source to see which parts can be debugged.
42
43       no_wrap
44           Comma-separated list of environments which should not be re-
45           wrapped.
46
47           Note that there is a difference between verbatim and no_wrap
48           environments.  There is no command and comments analysis in
49           verbatim blocks.
50
51           If this environment was not already registered, po4a will consider
52           that this environment does not take any parameters.
53
54       exclude_include
55           Colon-separated list of files that should not be included by \input
56           and \include.
57
58       definitions
59           The name of a file containing definitions for po4a, as defined in
60           the INLINE CUSTOMIZATION section.  You can use this option if it is
61           not possible to put the definitions in the document being
62           translated.
63
64       verbatim
65           Comma-separated list of environments which should be taken as
66           verbatim.
67
68           If this environment was not already registered, po4a will consider
69           that this environment does not take any parameters.
70
71       Using these options permits to override the behaviour of the commands
72       defined in the default lists.
73

INLINE CUSTOMIZATION

75       The TeX module can be customized with lines starting by % po4a:.  These
76       lines are interpreted as commands to the parser.  The following
77       commands are recognized:
78
79       % po4a: command command1 alias command2
80           Indicates that the arguments of the command1 command should be
81           treated as the arguments of the command2 command.
82
83       % po4a: command command1 parameters
84           This permit to describe in detail the parameters of the command1
85           command.  This information will be used to check the number of
86           arguments and their types.
87
88           You can precede the command1 command by
89
90           an asterisk (*)
91               po4a will extract this command from paragraphs (if it is
92               located at the beginning or the end of a paragraph).  The
93               translators will then have to translate the parameters that are
94               marked as translatable.
95
96           a plus (+)
97               As for an asterisk, the command will be extracted if it appear
98               at an extremity of a block, but the parameters won't be
99               translated separately.  The translator will have to translate
100               the command concatenated to all its parameters.  This permits
101               to keep more context, and is useful for commands with small
102               words in parameter, which can have multiple meanings (and
103               translations).
104
105               Note: In this case you don't have to specify which parameters
106               are translatable, but po4a must know the type and number of
107               parameters.
108
109           a minus (-)
110               In this case, the command won't be extracted from any block.
111               But if it appears alone on a block, then only the parameters
112               marked as translatable will be presented to the translator.
113               This is useful for font commands.  These commands should
114               generally not be separated from their paragraph (to keep the
115               context), but there is no reason to annoy the translator with
116               them if a whole string is enclosed in such a command.
117
118           The parameters argument is a set of [] (to indicate an optional
119           argument) or {} (to indicate a mandatory argument).  You can place
120           an underscore (_) between these brackets to indicate that the
121           parameter must be translated. For example:
122            % po4a: command *chapter [_]{_}
123
124           This indicates that the chapter command has two parameters: an
125           optional (short title) and a mandatory one, which must both be
126           translated.  If you want to specify that the href command has two
127           mandatory parameters, that you don't want to translate the URL
128           (first parameter), and that you don't want this command to be
129           separated from its paragraph (which allow the translator to move
130           the link in the sentence), you can use:
131            % po4a: command -href {}{_}
132
133           In this case, the information indicating which arguments must be
134           translated is only used if a paragraph is only composed of this
135           href command.
136
137       % po4a: environment env parameters
138           This permits to define the parameters accepted by the env
139           environment.  This information is later used to check the number of
140           arguments of the \begin command, and permit to specify which one
141           must be translated.  The syntax of the parameters argument is the
142           same as described for the others commands.  The first parameter of
143           the \begin command is the name of the environment.  This parameter
144           must not be specified in the list of parameters. Here are some
145           examples:
146            % po4a: environment multicols {}
147            % po4a: environment equation
148
149           As for the commands, env can be preceded by a plus (+) to indicate
150           that the \begin command must be translated with all its arguments.
151
152       % po4a: separator env "regex"
153           Indicates that an environment should be split according to the
154           given regular expression.
155
156           The regular expression is delimited by quotes.  It should not
157           create any backreference.  You should use (?:) if you need a group.
158           It may also need some escapes.
159
160           For example, the LaTeX module uses the "(?:&|\\\\)" regular
161           expression to translate separately each cell of a table (lines are
162           separated by '\\' and cells by '&').
163
164           The notion of environment is expended to the type displayed in the
165           PO file.  This can be used to split on "\\\\" in the first
166           mandatory argument of the title command.  In this case, the
167           environment is title{#1}.
168
169       % po4a: verbatim environment env
170           Indicate that env is a verbatim environment.  Comments and commands
171           will be ignored in this environment.
172
173           If this environment was not already registered, po4a will consider
174           that this environment does not take any parameters.
175

WRITING DERIVATE MODULES

177       pre_trans
178       post_trans
179       translate
180           Wrapper around Transtractor's translate, with pre- and post-
181           processing filters.
182
183           Comments of a paragraph are inserted as a PO comment for the first
184           translated string of this paragraph.
185
186       get_leading_command($buffer)
187           This function returns:
188
189           A command name
190               If no command is found at the beginning of the given buffer,
191               this string will be empty.  Only commands that can be separated
192               are considered.  The %separated_command hash contains the list
193               of these commands.
194
195           A variant
196               This indicates if a variant is used.  For example, an asterisk
197               (*) can be added at the end of sections command to specify that
198               they should not be numbered.  In this case, this field will
199               contain "*".  If there is no variant, the field is an empty
200               string.
201
202           An array of tuples (type of argument, argument)
203               The type of argument can be either '{' (for mandatory
204               arguments) or '[' (for optional arguments).
205
206           The remaining buffer
207               The rest of the buffer after the removal of this leading
208               command and its arguments.  If no command is found, the
209               original buffer is not touched and returned in this field.
210
211       get_trailing_command($buffer)
212           The same as get_leading_command, but for commands at the end of a
213           buffer.
214
215       translate_buffer
216           Recursively translate a buffer by separating leading and trailing
217           commands (those which should be translated separately) from the
218           buffer.
219
220           If a function is defined in %translate_buffer_env for the current
221           environment, this function will be used to translate the buffer
222           instead of translate_buffer().
223
224       read
225           Overloads Transtractor's read().
226
227       read_file
228           Recursively read a file, appending included files which are not
229           listed in the @exclude_include array.  Included files are searched
230           using the kpsewhich command from the Kpathsea library.
231
232           Except from the file inclusion part, it is a cut and paste from
233           Transtractor's read.
234
235       parse_definition_file
236           Subroutine for parsing a file with po4a directives (definitions for
237           new commands).
238
239       parse_definition_line
240           Parse a definition line of the form "% po4a: ".
241
242           See the INLINE CUSTOMIZATION section for more details.
243
244       is_closed
245       parse
246       docheader
247

INTERNAL FUNCTIONS used to write derivated parsers

249       Command and environment functions take the following arguments (in
250       addition to the $self object):
251
252       A command name
253       A variant
254       An array of (type, argument) tuples
255       The current environment
256
257       The first 3 arguments are extracted by get_leading_command or
258       get_trailing_command.
259
260       Command and environment functions return the translation of the command
261       with its arguments and a new environment.
262
263       Environment functions are called when a \begin command is found. They
264       are called with the \begin command and its arguments.
265
266       The TeX module only proposes one command function and one environment
267       function: generic_command and generic_environment.
268
269       generic_command uses the information specified by
270       register_generic_command or by adding definition to the TeX file:
271        % po4a: command command1 parameters
272
273       generic_environment uses the information specified by
274       register_generic_environment or by adding definition to the TeX file:
275        % po4a: environment env parameters
276
277       Both functions will only translate the parameters that were specified
278       as translatable (with a '_').  generic_environment will append the name
279       of the environment to the environment stack and generic_command will
280       append the name of the command followed by an identifier of the
281       parameter (like {#7} or [#2]).
282

STATUS OF THIS MODULE

284       This module needs more tests.
285
286       It was tested on a book and with the Python documentation.
287

TODO LIST

289       Automatic detection of new commands
290           The TeX module could parse the newcommand arguments and try to
291           guess the number of arguments, their type and whether or not they
292           should be translated.
293
294       Translation of the environment separator
295           When \item is used as an environment separator, the item argument
296           is attached to the following string.
297
298       Some commands should be added to the environment stack
299           These commands should be specified by couples.  This could allow to
300           specify commands beginning or ending a verbatim environment.
301
302       Others
303           Various other points are tagged TODO in the source.
304

KNOWN BUGS

306       Various points are tagged FIXME in the source.
307

SEE ALSO

309       Locale::Po4a::LaTeX(3pm), Locale::Po4a::TransTractor(3pm), po4a(7)
310

AUTHORS

312        Nicolas François <nicolas.francois@centraliens.net>
313
315       Copyright 2004, 2005 by Nicolas FRANÇOIS
316       <nicolas.francois@centraliens.net>.
317
318       This program is free software; you may redistribute it and/or modify it
319       under the terms of GPL (see the COPYING file).
320
321
322
323Po4a Tools                        2019-02-02            Locale::Po4a::TeX(3pm)
Impressum