msgfilter Programmsgfilter [option] filter [filter-option]
The msgfilter program applies a filter to all translations of a
translation catalog.
During each filter invocation, the environment variable
MSGFILTER_MSGID is bound to the message's msgid, and the environment
variable MSGFILTER_LOCATION is bound to the location in the PO file
of the message. If the message has a context, the environment variable
MSGFILTER_MSGCTXT is bound to the message's msgctxt, otherwise it is
unbound.
If no inputfile is given or if it is ‘-’, standard input is read.
The results are written to standard output if no output file is specified or if it is ‘-’.
The filter can be any program that reads a translation from standard input and writes a modified translation to standard output. A frequently used filter is ‘sed’. A few particular built-in filters are also recognized.
Note: If the filter is not a built-in filter, you have to care about encodings:
It is your responsibility to ensure that the filter can cope
with input encoded in the translation catalog's encoding. If the
filter wants input in a particular encoding, you can in a first step
convert the translation catalog to that encoding using the ‘msgconv’
program, before invoking ‘msgfilter’. If the filter wants input
in the locale's encoding, but you want to avoid the locale's encoding, then
you can first convert the translation catalog to UTF-8 using the
‘msgconv’ program and then make ‘msgfilter’ work in an UTF-8
locale, by using the LC_ALL environment variable.
Note: Most translations in a translation catalog don't end with a newline
character. For this reason, it is important that the filter
recognizes its last input line even if it ends without a newline, and that
it doesn't add an undesired trailing newline at the end. The ‘sed’
program on some platforms is known to ignore the last line of input if it
is not terminated with a newline. You can use GNU sed instead; it
does not have this limitation.
The filter ‘recode-sr-latin’ is recognized as a built-in filter. The command ‘recode-sr-latin’ converts Serbian text, written in the Cyrillic script, to the Latin script. The command ‘msgfilter recode-sr-latin’ applies this conversion to the translations of a PO file. Thus, it can be used to convert an sr.po file to an sr@latin.po file.
The use of built-in filters is not sensitive to the current locale's encoding. Moreover, when used with a built-in filter, ‘msgfilter’ can automatically convert the message catalog to the UTF-8 encoding when needed.
.properties
syntax, not in PO file syntax.
.strings syntax, not in PO file syntax.
--color.
See The –style option for details.
.properties syntax. Note
that this file format doesn't support plural forms and silently drops
obsolete messages.
.strings syntax.
Note that this file format doesn't support plural forms.
To convert German translations to Swiss orthography (in an UTF-8 locale):
msgconv -t UTF-8 de.po | msgfilter sed -e 's/ß/ss/g'
To convert Serbian translations in Cyrillic script to Latin script:
msgfilter recode-sr-latin < sr.po