Gettext/Manipulating
9 Manipulating PO Files
Sometimes it is necessary to manipulate PO files in a way that is better
performed automatically than by hand. GNU gettext
includes a
complete set of tools for this purpose.
When merging two packages into a single package, the resulting POT file
will be the concatenation of the two packages’ POT files. Thus the
maintainer must concatenate the two existing package translations into
a single translation catalog, for each language. This is best performed
using ‘msgcat
’. It is then the translators’ duty to deal with any
possible conflicts that arose during the merge.
When a translator takes over the translation job from another translator,
but she uses a different character encoding in her locale, she will
convert the catalog to her character encoding. This is best done through
the ‘msgconv
’ program.
When a maintainer takes a source file with tagged messages from another
package, he should also take the existing translations for this source
file (and not let the translators do the same job twice). One way to do
this is through ‘msggrep
’, another is to create a POT file for
that source file and use ‘msgmerge
’.
When a translator wants to adjust some translation catalog for a special
dialect or orthography — for example, German as written in Switzerland
versus German as written in Germany — she needs to apply some text
processing to every message in the catalog. The tool for doing this is
‘msgfilter
’.
Another use of msgfilter
is to produce approximately the POT file for
which a given PO file was made. This can be done through a filter command
like ‘msgfilter sed -e d | sed -e '/^# /d'
’. Note that the original
POT file may have had different comments and different plural message counts,
that’s why it’s better to use the original POT file if available.
When a translator wants to check her translations, for example according
to orthography rules or using a non-interactive spell checker, she can do
so using the ‘msgexec
’ program.
When third party tools create PO or POT files, sometimes duplicates cannot
be avoided. But the GNU gettext
tools give an error when they
encounter duplicate msgids in the same file and in the same domain.
To merge duplicates, the ‘msguniq
’ program can be used.
‘msgcomm
’ is a more general tool for keeping or throwing away
duplicates, occurring in different files.
‘msgcmp
’ can be used to check whether a translation catalog is
completely translated.
‘msgattrib
’ can be used to select and extract only the fuzzy
or untranslated messages of a translation catalog.
‘msgen
’ is useful as a first step for preparing English translation
catalogs. It copies each message’s msgid to its msgstr.
Finally, for those applications where all these various programs are not
sufficient, a library ‘libgettextpo
’ is provided that can be used to
write other specialized programs that process PO files.
• msgcat Invocation: | Invoking the msgcat Program
| |
• msgconv Invocation: | Invoking the msgconv Program
| |
• msggrep Invocation: | Invoking the msggrep Program
| |
• msgfilter Invocation: | Invoking the msgfilter Program
| |
• msguniq Invocation: | Invoking the msguniq Program
| |
• msgcomm Invocation: | Invoking the msgcomm Program
| |
• msgcmp Invocation: | Invoking the msgcmp Program
| |
• msgattrib Invocation: | Invoking the msgattrib Program
| |
• msgen Invocation: | Invoking the msgen Program
| |
• msgexec Invocation: | Invoking the msgexec Program
| |
• Colorizing: | Highlighting parts of PO files | |
• Other tools: | Other tools for manipulating PO files | |
• libgettextpo: | Writing your own programs that process PO files |