1PO4A(1p)                          Po4a Tools                          PO4A(1p)
2
3
4

NAME

6       po4a - update both the PO files and translated documents in one shot
7

SYNOPSIS

9       po4a [options] config_file
10

DESCRIPTION

12       The po4a (PO for anything) project goal is to ease translations (and
13       more interestingly, the maintenance of translations) using gettext
14       tools on areas where they were not expected like documentation.
15
16       The po4a program is useful if you want to avoid calling
17       po4a-gettextize(1), po4a-updatepo(1), and po4a-translate(1) in complex
18       Makefiles when you have multiple files to translate, different format,
19       or need to specify different options for different documents.
20

Table of content

22       This document is organized as follow:
23
24   DESCRIPTION
25   INTRODUCTION
26   CONFIGURATION FILE SYNTAX
27       Specifying the template languages
28
29       Specifying the paths to translator inputs
30
31       Autodetection of the paths and languages
32
33       Specifying the documents to translate
34
35       Specifying options for the modules
36
37       Specifying aliases
38
39       Split mode
40
41   OPTIONS
42   EXAMPLE
43   SHORTCOMINGS
44   SEE ALSO
45   AUTHORS
46   COPYRIGHT AND LICENSE
47
48

INTRODUCTION

50       The po4a program is in charge of updating both the PO files (to sync
51       them to the original documents) and the translated documents (to sync
52       them to the PO files). The main point is to make the use of po4a easier
53       without having to remember of the command line options.
54
55       It also allows you to mix documents having different formats into the
56       same POT file so that you can have only one such file per project.
57
58       This behaviour can be mimicked by the other tools of the po4a suite
59       (for example with Makefiles), but it is rather difficult to do, and
60       exhausting to redo the same complicated Makefiles for each project
61       using po4a.
62
63       The dataflow can be summarized as follow. Any changes to the master
64       document will be reflected in the PO files, and all changes to the PO
65       files (either manual or caused by previous step) will be reflected in
66       translation documents.
67
68        master document --> PO files --> translations
69
70       The dataflow cannot be inversed in this tool, and changes in
71       translations are overwritten by the content of the PO files. As a
72       matter of fact, this tool cannot be used to convert existing
73       translations to the po4a system. For that task, please refer to
74       po4a-gettextize(1).
75

CONFIGURATION FILE SYNTAX

77       The (mandatory) argument is the path to the configuration file to use.
78       Its syntax aims at being simple and close to the configuration files
79       used by the intl-tools projects.
80
81       Comments in these files are noted by the char '#'. It comments
82       everything until the end of the line. Lines can be continued by
83       escaping the end of line.  All non blank lines must begin with a []
84       command, followed by its arguments.  (sound difficult said that way,
85       but it is rather easy, I hope ;)
86
87   Specifying the template languages
88       Note: It is recommended to use [po_directory] rather than [po4a_langs]
89       and [po4a_paths].  See section Autodetection of the paths and languages
90       below.
91
92       This is an optional command that can simplify the whole config file,
93       and will make it more scalable. You have to specify a list of the
94       languages in which you want to translate the documents. This is as
95       simple as:
96
97        [po4a_langs] fr de
98
99       This will enable you to expand $lang to all the specified languages in
100       the rest of the config file.
101
102   Specifying the paths to translator inputs
103       Note: It is recommended to use [po_directory] rather than [po4a_langs]
104       and [po4a_paths].  See section Autodetection of the paths and languages
105       below.
106
107       First, you have to specify where the translator input files (I.E. the
108       files used by translators to do their job) are located. It can be done
109       by such a line:
110
111        [po4a_paths] doc/l10n/project.doc.pot \
112                     fr:doc/l10n/fr.po de:doc/l10n/de.po
113
114       The command is thus [po4a_paths]. The first argument is the path to the
115       POT file to use. All subsequent arguments are of the self-explanatory
116       form:
117
118           <lang>:<path to the PO file for this lang>
119
120       If you've defined the template languages, you can rewrite the line
121       above this way:
122
123        [po4a_paths] doc/l10n/project.doc.pot $lang:doc/l10n/$lang.po
124
125       You can also use $master to refer to the document filename. In this
126       case, po4a will use a split mode: one POT and one PO (for each
127       language) will be created for each document specified in the po4a
128       configuration file.  See the Split mode section.
129
130        [po4a_paths] doc/$master/$master.pot $lang:doc/$master/$lang.po
131
132   Autodetection of the paths and languages
133       Another command can be used to specify the name of a directory where
134       the PO and POT files are located.  When it is used, po4a will detect
135       the POT file as the only *.pot file from the specified directory.  po4a
136       will also use the list of *.po files to define the list of languages
137       (by stripping out the extension).  These languages will be used for the
138       substitution of the $lang variable in the rest of the configuration
139       file.
140
141       This command should not be used together with the [po4a_langs] or
142       [po4a_paths] commands.
143
144       When using this command, you have to create an empty POT file on the
145       first invocation of po4a to let it know the name of the POT file.
146
147        [po_directory] po4a/po/
148
149   Specifying the documents to translate
150       You now naturally have to specify which documents are translated, their
151       format, and where to put the translations. It can be made by such
152       lines:
153
154        [type: sgml] doc/my_stuff.sgml fr:doc/fr/mon_truc.sgml \
155                     de:doc/de/mein_kram.sgml
156        [type: pod] script fr:doc/fr/script.1 de:doc/de/script.1 \
157                    add_fr:doc/l10n/script.fr.add
158
159       This should be rather self-explanatory also. Note that in the second
160       case, doc/l10n/script.fr.add is an addendum to add to the French
161       version of this document.  Please refer to po4a(7) for more information
162       about the addenda.
163
164       More formally, the format is:
165
166        [type: <format>] <master_doc> (<lang>:<localized_doc>)* \
167                         (add_<lang>:<modifier>*<addendum_path>)*
168
169       If there is no modifier, addendum_path is a path to an addendum.
170       Modifiers are
171
172       ? Include addendum_path if this file does exist, otherwise do nothing.
173
174       @ addendum_path is not a regular addendum but a file containing a list
175         of addenda, one by line.  Each addendum may be preceded by modifiers.
176
177       ! addendum_path is discarded, it is not loaded and will not be loaded
178         by any further addendum specification.
179
180       If you've defined the template languages, you can rewrite the line
181       above this way:
182
183        [type: pod] script $lang:doc/$lang/script.1 \
184                    add_fr:doc/l10n/script.fr.add
185
186       If all the languages had addenda with similar paths, you could also
187       write something like:
188
189        [type: pod] script $lang:doc/$lang/script.1 \
190                    add_$lang:doc/l10n/script.$lang.add
191
192   Specifying options for the modules
193       po4a accepts options that will be passed to the module. These options
194       are module specific and are specified with the -o switch.
195
196       If you need a specific option for one of the documents you want to
197       translate, you can also specify it in the configuration file. Options
198       are introduced by the opt keyword. The argument of the opt keyword must
199       be quoted with double quotes if it contains a space (e.g. if you
200       specify multiple options, or an option with an argument).  You can also
201       specify options that will only apply to a specific language by using
202       the opt_lang keyword.
203
204       Here is an example:
205        [type:man] t-05-config/test02_man.1 $lang:tmp/test02_man.$lang.1 \
206                   opt:"-k 75" opt_it:"-L UTF-8" opt_fr:-v
207
208       Arguments may contain spaces if you use single quotes or escaped double
209       quotes:
210        [po4a_alias:man] man opt:"-o \"mdoc=NAME,SEE ALSO\" -k 20"
211
212       If you want to specify the same options for many documents, you may
213       want to use an alias (see the Specifying aliases section below).
214
215       You can also set options for all the documents specified in the
216       configuration file:
217        [options] opt:"..." opt_fr:"..."
218
219   Specifying aliases
220       If you must specify the same options for multiple files, you may be
221       interested in defining a module alias. This can be done this way:
222
223        [po4a_alias:test] man opt:"-k 21" opt_es:"-o debug=splitargs"
224
225       This defines a module alias named test, based on the man module, with
226       the -k 21 applied to all the languages and with -o debug=splitargs
227       applied to the Spanish translation.
228
229       This module alias can then be used like a regular module:
230
231        [type:test] t-05-config/test02_man.1 $lang:tmp/test02_man.$lang.1 \
232                   opt_it:"-L UTF-8" opt_fr:-v
233
234       Note that you can specify additional options on a per file basis.
235
236   Split mode
237       The split mode is used when $master is used in the [po4a_paths] line.
238
239       When the split mode is used, a temporary big POT and temporary big POs
240       are used. This permits to share the translations between all the POs.
241
242       If two POs have different translations for the same string, po4a will
243       mark this string as fuzzy and will submit both translations in all the
244       POs which contain this string. Then, when a translator updates the
245       translation and removes the fuzzy tag in one PO, the translation of
246       this string will be updated in every POs automatically.
247
248       If there are name conflicts because several files have the same
249       filename, the name of the master file can be specified by adding a
250       "master:file="name option:
251
252        [po4a_langs] de fr ja
253        [po4a_paths] l10n/po/$master.pot $lang:l10n/po/$master.$lang.po
254        [type: xml] foo/gui.xml $lang:foo/gui.$lang.xml master:file=foo-gui
255        [type: xml] bar/gui.xml $lang:bar/gui.$lang.xml master:file=bar-gui
256

OPTIONS

258       -k, --keep
259           Minimal threshold for translation percentage to keep (i.e. write)
260           the resulting file (default: 80). I.e. by default, files have to be
261           translated at least at 80% to get written.
262
263       -h, --help
264           Show a short help message.
265
266       -M, --master-charset
267           Charset of the files containing the documents to translate. Note
268           that all master documents must use the same charset for now. This
269           is a known limitation, and we are working on solving this.
270
271       -L, --localized-charset
272           Charset of the files containing the localized documents. Note that
273           all translated documents will use the same charset for now. This is
274           a known limitation, and we are working on solving this.
275
276       -A, --addendum-charset
277           Charset of the addenda. Note that all the addenda should be in the
278           same charset.
279
280       -V, --version
281           Display the version of the script and exit.
282
283       -v, --verbose
284           Increase the verbosity of the program.
285
286       -q, --quiet
287           Decrease the verbosity of the program.
288
289       -d, --debug
290           Output some debugging information.
291
292       -o, --option
293           Extra option(s) to pass to the format plugin. Specify each option
294           in the 'name=value' format. See the documentation of each plugin
295           for more information about the valid options and their meanings.
296
297       -f, --force
298           Always generate the POT and PO files, even if po4a considers it is
299           not necessary.
300
301           The default behavior (when --force is not specified) is the
302           following:
303
304               If the POT file already exists, it is regenerated if a master
305               document or the configuration file is more recent.  The POT
306               file is also written in a temporary document and po4a verifies
307               that the changes are really needed.
308
309               Also, a translation is regenerated only if its master document,
310               the PO file, one of its addenda or the configuration file is
311               more recent.  To avoid trying to regenerate translations which
312               do not pass the threshold test (see --keep), a file with the
313               .po4a-stamp extension can be created (see --stamp).
314
315           If a master document includes files, you should use the --force
316           flag because the modification time of these included files are not
317           taken into account.
318
319           The PO files are always re-generated based on the POT with msgmerge
320           -U.
321
322       --stamp
323           Tells po4a to create stamp files when a translation is not
324           generated because it does not reach the threshold. These stamp
325           files are named according to the expected translated document, with
326           the .po4a-stamp extension.
327
328           Note: This only activates the creation of the .po4a-stamp files.
329           The stamp files are always used if they exist, and they are removed
330           with --rm-translations or when the file is finally translated.
331
332       --no-translations
333           Do not generate the translated documents, only update the POT and
334           PO files.
335
336       --no-update
337           Do not change the POT and PO files, only the translation may be
338           updated.
339
340       --keep-translations
341           Keeps the existing translation files even if the translation
342           doesn't meet the threshold specified by --keep.  This option does
343           not create new translation files with few content, but it will save
344           existing translations which decay because of changes to the master
345           files.
346
347           WARNING: This flag changes the po4a behavior in a rather drastic
348           way: your translated files will not get updated at all until the
349           translation improves. Only use this flag if you prefer shipping an
350           outdated translated documentation rather than only shipping an
351           accurate untranslated documentation.
352
353       --rm-translations
354           Remove the translated files (implies --no-translations).
355
356       --no-backups
357           This flag does nothing since 0.41, and may be removed in later
358           releases.
359
360       --rm-backups
361           This flag does nothing since 0.41, and may be removed in later
362           releases.
363
364       --translate-only translated-file
365           Translate only the specified file.  It may be useful to speed up
366           processing if a configuration file contains a lot of files.  Note
367           that this option does not update PO and POT files.  This option can
368           be used multiple times.
369
370       --variable var=value
371           Define a variable that will be expanded in the po4a configuration
372           file.  Every occurrence of $(var) will be replaced by value.  This
373           option can be used multiple times.
374
375       --srcdir SRCDIR
376           Set the base directory for all input documents specified in the
377           po4a configuration file.
378
379       --destdir DESTDIR
380           Set the base directory for all the output documents specified in
381           the po4a configuration file.
382
383   OPTIONS WHICH MODIFY POT HEADER
384       --porefs type[,wrap|nowrap]
385           Specify the reference format. Argument type can be one of never to
386           not produce any reference, file to only specify the file without
387           the line number, counter to replace line number by an increasing
388           counter, and full to include complete references (default: full).
389
390           Argument can be followed by a comma and either wrap or nowrap
391           keyword.  References are written by default on a single line.  The
392           wrap option wraps references on several lines, to mimic gettext
393           tools (xgettext and msgmerge).  This option will become the default
394           in a future release, because it is more sensible.  The nowrap
395           option is available so that users who want to keep the old behavior
396           can do so.
397
398       --msgid-bugs-address email@address
399           Set the report address for msgid bugs. By default, the created POT
400           files have no Report-Msgid-Bugs-To fields.
401
402       --copyright-holder string
403           Set the copyright holder in the POT header. The default value is
404           "Free Software Foundation, Inc."
405
406       --package-name string
407           Set the package name for the POT header. The default is "PACKAGE".
408
409       --package-version string
410           Set the package version for the POT header. The default is
411           "VERSION".
412
413   OPTIONS TO MODIFY PO FILES
414       --msgmerge-opt options
415           Extra options for msgmerge(1).
416
417           Note: $lang will be extended to the current language.
418
419       --no-previous
420           This option removes --previous from the options passed to msgmerge.
421           This permits to support versions of gettext earlier than 0.16.
422
423       --previous
424           This option adds --previous to the options passed to msgmerge.  It
425           requires gettext 0.16 or later, and is activated by default.
426
427   EXAMPLE
428       Let's assume you maintain a program named foo which has a man page
429       man/foo.1 which naturally is maintained in English only. Now you as the
430       upstream or downstream maintainer want to create and maintain the
431       translation.  First you need to create the POT file necessary to send
432       to translators using po4a-gettextize(1).
433
434       So for our case we would call
435
436        cd man && po4a-gettextize -f man -m foo.1 -p foo.pot
437
438       You would then send this file to the appropriate language lists or
439       offer it for download somewhere on your website.
440
441       Now let's assume you received three translations before your next
442       release: de.po (including an addendum de.add), sv.po and pt.po.  Since
443       you don't want to change your Makefile(s) whenever a new translation
444       arrives you can use po4a with an appropriate configuration file in your
445       Makefile.  Let's call it po4a.cfg. In our example it would look like
446       the following:
447
448        [po_directory] man/po4a/po/
449
450        [type: man] man/foo.1 $lang:man/translated/$lang/foo.1 \
451                   add_$lang:?man/po4a/add_$lang/$lang.add opt:"-k 80"
452
453       In this example we assume that your generated man pages (and all PO and
454       addenda files) should be stored in man/translated/$lang/ (respectively
455       in man/po4a/po/ and man/po4a/add_$lang/) below the current directory.
456       In our example the man/po4a/po/ directory would include de.po, pt.po
457       and sv.po, and the man/po4a/add_de/ directory would include de.add.
458
459       Note the use of the modifier ? as only the German translation (de.po)
460       is accompanied by an addendum.
461
462       To actually build the translated man pages you would then (once!) add
463       the following line in the build target of the appropriate Makefile:
464
465               po4a po4a.cfg
466
467       Once this is set up you don't need to touch the Makefile when a new
468       translation arrives, i.e. if the French team sends you fr.po and fr.add
469       then you simply drop them respectively in man/po4a/po/ and
470       man/po4a/add_fr/ and the next time the program is built the French
471       translation is automatically build as well in man/translated/fr/.
472
473       Note that you still need an appropriate target to install localized
474       manual pages with English ones.
475
476       Finally if you do not store generated files into your version control
477       system, you will need a line in your clean target as well:
478               -rm -rf man/translated
479

SHORTCOMINGS

481       ·   Duplicates some code with the po4a-* programs.
482
483       Patch welcome ;)
484

SEE ALSO

486       po4a-build(1), po4a-gettextize(1), po4a-normalize(1),
487       po4a-translate(1), po4a-updatepo(1), po4a-build.conf(5), po4a(7)
488

AUTHORS

490        Denis Barbier <barbier@linuxfr.org>
491        Nicolas François <nicolas.francois@centraliens.net>
492        Martin Quinson (mquinson#debian.org)
493
495       Copyright 2002-2012 by SPI, inc.
496
497       This program is free software; you may redistribute it and/or modify it
498       under the terms of GPL (see the COPYING file).
499
500
501
502Po4a Tools                        2019-02-02                          PO4A(1p)
Impressum