The po4a program is useful if you want to avoid calling po4a-gettextize(1), po4a-updatepo(1), and po4a-translate(1) in complex Makefiles when you have multiple files to translate, different format, or need to specify different options for different documents.
Specifying the paths to translator inputs
Autodetection of the paths and languages
Specifying the documents to translate
Specifying options for the modules
It also allows you to mix documents having different formats into the same POT file so that you can have only one such file per project.
This behaviour can be mimicked by the other tools of the po4a suite (for example with Makefiles), but it is rather difficult to do, and exhausting to redo the same complicated Makefiles for each project using po4a.
The dataflow can be summarized as follow. Any changes to the master document will be reflected in the PO files, and all changes to the PO files (either manual or caused by previous step) will be reflected in translation documents.
master document --> PO files --> translations
The dataflow cannot be inversed in this tool, and changes in translations are overwritten by the content of the PO files. As a matter of fact, this tool cannot be used to convert existing translations to the po4a system. For that task, please refer to po4a-gettextize(1).
Comments in this files are noted by the char '#'. It comments everything until the end of the line. Lines can be continued by escaping the end of line. All non blank lines must begin with a  command, followed by its arguments. (sound difficult said that way, but it is rather easy, I hope ;)
This is an optional command that can simplify the whole config file, and will make it more scalable. You have to specify a list of the languages in which you want to translate the documents. This is as simple as:
[po4a_langs] fr de
First, you have to specify where the translator input files (i.e. the files used by translators to do their job) are located. It can be done by such a line:
[po4a_paths] doc/l10n/project.doc.pot \ fr:doc/l10n/fr.po de:doc/l10n/de.po
The command is thus [po4a_paths]. The first argument is the path to the POT file to use. All subsequent arguments are of the self-explanatory form:
<lang>:<path to the PO file for this lang>
If you've defined the template languages, you can rewrite the line above this way:
[po4a_paths] doc/l10n/project.doc.pot $lang:doc/l10n/$lang.po
You can also use $master to refer to the document filename. In this case, po4a will use a split mode: one POT and one PO (for each language) will be created for each document specified in the po4a configuration file. See the Split mode section.
[po4a_paths] doc/$master/$master.pot $lang:doc/$master/$lang.po
This command should not be used together with the [po4a_langs] or [po4a_paths] commands.
When using this command, you have to create an empty POT file on the first invocation of po4a to let it know the name of the POT file.
[type: sgml] doc/my_stuff.sgml fr:doc/fr/mon_truc.sgml \ de:doc/de/mein_kram.sgml [type: pod] script fr:doc/fr/script.1 de:doc/de/script.1 \ add_fr:doc/l10n/script.fr.add
This should be rather self-explanatory also. Note that in the second case, doc/l10n/script.fr.add is an addendum to add to the French version of this document. Please refer to po4a(7) for more information about the addenda.
More formally, the format is:
[type: <format>] <master_doc> (<lang>:<localized_doc>)* \ (add_<lang>:<modifier>*<addendum_path>)*
If there is no modifier, addendum_path is a path to an addendum. Modifiers are
If you've defined the template languages, you can rewrite the line above this way:
[type: pod] script $lang:doc/$lang/script.1 \ add_fr:doc/l10n/script.fr.add
If all the languages had addenda with similar paths, you could also write something like:
[type: pod] script $lang:doc/$lang/script.1 \ add_$lang:doc/l10n/script.$lang.add
If you need a specific option for one of the document you want to translate, you can also specify it in the configuration file. Options are introduced by the opt keyword. The argument of the opt keyword must be quoted with double quotes if it contains a space (e.g. if you specify multiple options, or an option with an argument). You can also specify options that will only apply to a specific language by using the opt_lang keyword.
Here is an example:
[type:man] data-05/test2_man.1 $lang:tmp/test2_man.$lang.1 \
opt:``-k 75'' opt_it:``-L UTF-8'' opt_fr:-v
Arguments may contain spaces if you use single quotes or escaped double
[po4a_alias:man] man opt:``-o \''mdoc=NAME,SEE ALSO\`` -k 20''
If you want to specify the same options for many documents, you may want to use an alias (see the Specifying aliases section below).
[po4a_alias:test] man opt:"-k 21" opt_es:"-o debug=splitargs"
This defines a module alias named test, based on the man module, with the -k 21 applied to all the languages and with -o debug=splitargs applied to the Spanish translation.
This module alias can then be use like a regular module:
[type:test] data-05/test2_man.1 $lang:tmp/test2_man.$lang.1 \ opt_it:"-L UTF-8" opt_fr:-v
When the split mode is used, a temporary big POT and temporary big POs are used. This permits to share the translations between all the POs.
If two POs have different translations for the same string, po4a will mark this string as fuzzy and will submit both translations in all the POs which contain this string. Then, when a translator updates the translation and removes the fuzzy tag in one PO, the translation of this string will be updated in every POs automatically.
If there are name conflicts because several files have the same filename, the name of the master file can be specified by adding a "master:file="name option:
[po4a_langs] de fr ja [po4a_paths] l10n/po/$master.pot $lang:l10n/po/$master.$lang.po [type: xml] foo/gui.xml $lang:foo/gui.$lang.xml master:file=foo-gui [type: xml] bar/gui.xml $lang:bar/gui.$lang.xml master:file=bar-gui
The default behavior (when --force is not specified) is the following:
Also, a translation is regenerated only if its master document, the PO file, one of its addenda or the configuration file is more recent. To avoid trying to regenerate translations which do not pass the threshold test (see --keep), a file with the .po4a-stamp extension can be created (see --stamp).
If a master document includes files, you should use the --force flag because the modification time of these included files are not taken into account.
The PO files are always re-generated based on the POT with msgmerge -U.
Note: This only activates the creation of the .po4a-stamp files. The stamp files are always used if they exist, and they are removed with --rm-translations or when the file is finally translated.
Argument can be followed by a comma and either wrap or nowrap keyword. References are written by default on a single line. The wrap option wraps references on several lines, to mimic gettext tools (xgettext and msgmerge). This option will become the default in a future release, because it is more sensible. The nowrap option is available so that users who want to keep the old behavior can do so.
Note: $lang will be extended to the current language.
So for our case we would call
cd man && po4a-gettextize -f man -m foo.1 -p foo.pot
You would then send this file to the appropriate language lists or offer it for download somewhere on your website.
Now let's assume you received three translations before your next release: de.po (including an addendum de.add), sv.po and pt.po. Since you don't want to change your Makefile(s) whenever a new translation arrives you can use po4a with an appropriate configuration file in your Makefile. Let's call it po4a.cfg. In our example it would look like the following:
[po_directory] man/po4a/po/ [type: man] man/foo.1 $lang:man/translated/$lang/foo.1 \ add_$lang:?man/po4a/add_$lang/$lang.add opt:"-k 80"
In this example we assume that your generated man pages (and all PO and addenda files) should be stored in man/translated/$lang/ (respectively in man/po4a/po/ and man/po4a/add_$lang/) below the current directory. In our example the man/po4a/po/ directory would include de.po, pt.po and sv.po, and the man/po4a/add_de/ directory would include de.add.
Note the use of the modifier ? as only the German translation (de.po) is accompanied by an addendum.
To actually build the translated man pages you would then (once!) add the following line in the build target of the appropriate Makefile:
Once this is set up you don't need to touch the Makefile when a new translation arrives, i.e. if the French team sends you fr.po and fr.add then you simply drop them respectively in man/po4a/po/ and man/po4a/add_fr/ and the next time the programm is build the French translation is automatically build as well in man/translated/fr/.
Note that you still need an appropriate target to install localized manual pages with English ones.
Denis Barbier <email@example.com> Nicolas François <firstname.lastname@example.org> Martin Quinson (mquinson#debian.org)
This program is free software; you may redistribute it and/or modify it under the terms of GPL (see the COPYING file).