1@pindex msgfilter 2@cindex @code{msgfilter} program, usage 3@example 4msgfilter [@var{option}] @var{filter} [@var{filter-option}] 5@end example 6 7@cindex apply a filter to translations 8The @code{msgfilter} program applies a filter to all translations of a 9translation catalog. 10 11@subsection Input file location 12 13@table @samp 14@item -i @var{inputfile} 15@itemx --input=@var{inputfile} 16@opindex -i@r{, @code{msgfilter} option} 17@opindex --input@r{, @code{msgfilter} option} 18Input PO file. 19 20@item -D @var{directory} 21@itemx --directory=@var{directory} 22@opindex -D@r{, @code{msgfilter} option} 23@opindex --directory@r{, @code{msgfilter} option} 24Add @var{directory} to the list of directories. Source files are 25searched relative to this list of directories. The resulting @file{.po} 26file will be written relative to the current directory, though. 27 28@end table 29 30If no @var{inputfile} is given or if it is @samp{-}, standard input is read. 31 32@subsection Output file location 33 34@table @samp 35@item -o @var{file} 36@itemx --output-file=@var{file} 37@opindex -o@r{, @code{msgfilter} option} 38@opindex --output-file@r{, @code{msgfilter} option} 39Write output to specified file. 40 41@end table 42 43The results are written to standard output if no output file is specified 44or if it is @samp{-}. 45 46@subsection The filter 47 48The @var{filter} can be any program that reads a translation from standard 49input and writes a modified translation to standard output. A frequently 50used filter is @samp{sed}. A few particular built-in filters are also 51recognized. 52 53@cindex @code{msgfilter} filter and catalog encoding 54Note: If the filter is not a built-in filter, you have to care about encodings: 55It is your responsibility to ensure that the @var{filter} can cope 56with input encoded in the translation catalog's encoding. If the 57@var{filter} wants input in a particular encoding, you can in a first step 58convert the translation catalog to that encoding using the @samp{msgconv} 59program, before invoking @samp{msgfilter}. If the @var{filter} wants input 60in the locale's encoding, but you want to avoid the locale's encoding, then 61you can first convert the translation catalog to UTF-8 using the 62@samp{msgconv} program and then make @samp{msgfilter} work in an UTF-8 63locale, by using the @code{LC_ALL} environment variable. 64 65@cindex portability problems with @code{sed} 66Note: Most translations in a translation catalog don't end with a newline 67character. For this reason, it is important that the @var{filter} 68recognizes its last input line even if it ends without a newline, and that 69it doesn't add an undesired trailing newline at the end. The @samp{sed} 70program on some platforms is known to ignore the last line of input if it 71is not terminated with a newline. You can use GNU @code{sed} instead; it 72does not have this limitation. 73 74@subsection Useful @var{filter-option}s when the @var{filter} is @samp{sed} 75 76@table @samp 77@item -e @var{script} 78@itemx --expression=@var{script} 79@opindex -e@r{, @code{msgfilter} option} 80@opindex --expression@r{, @code{msgfilter} option} 81Add @var{script} to the commands to be executed. 82 83@item -f @var{scriptfile} 84@itemx --file=@var{scriptfile} 85@opindex -f@r{, @code{msgfilter} option} 86@opindex --file@r{, @code{msgfilter} option} 87Add the contents of @var{scriptfile} to the commands to be executed. 88 89@item -n 90@itemx --quiet 91@itemx --silent 92@opindex -n@r{, @code{msgfilter} option} 93@opindex --quiet@r{, @code{msgfilter} option} 94@opindex --silent@r{, @code{msgfilter} option} 95Suppress automatic printing of pattern space. 96 97@end table 98 99@subsection Built-in @var{filter}s 100 101@pindex recode-sr-latin 102@cindex @code{recode-sr-latin} program 103The filter @samp{recode-sr-latin} is recognized as a built-in filter. 104The command @samp{recode-sr-latin} converts Serbian text, written in the 105Cyrillic script, to the Latin script. 106The command @samp{msgfilter recode-sr-latin} applies this conversion to the 107translations of a PO file. Thus, it can be used to convert an @file{sr.po} 108file to an @file{sr@@latin.po} file. 109 110The use of built-in filters is not sensitive to the current locale's encoding. 111Moreover, when used with a built-in filter, @samp{msgfilter} can automatically 112convert the message catalog to the UTF-8 encoding when needed. 113 114@subsection Input file syntax 115 116@table @samp 117@item -P 118@itemx --properties-input 119@opindex -P@r{, @code{msgfilter} option} 120@opindex --properties-input@r{, @code{msgfilter} option} 121Assume the input file is a Java ResourceBundle in Java @code{.properties} 122syntax, not in PO file syntax. 123 124@item --stringtable-input 125@opindex --stringtable-input@r{, @code{msgfilter} option} 126Assume the input file is a NeXTstep/GNUstep localized resource file in 127@code{.strings} syntax, not in PO file syntax. 128 129@end table 130 131@subsection Output details 132 133@c --no-escape and --escape omitted on purpose. They are not useful. 134 135@table @samp 136@item --force-po 137@opindex --force-po@r{, @code{msgfilter} option} 138Always write an output file even if it contains no message. 139 140@item --indent 141@opindex --indent@r{, @code{msgfilter} option} 142Write the .po file using indented style. 143 144@item --keep-header 145@opindex --keep-header@r{, @code{msgfilter} option} 146Keep the header entry, i.e.@: the message with @samp{msgid ""}, unmodified, 147instead of filtering it. By default, the header entry is subject to 148filtering like any other message. 149 150@item --no-location 151@opindex --no-location@r{, @code{msgfilter} option} 152Do not write @samp{#: @var{filename}:@var{line}} lines. 153 154@item --add-location 155@opindex --add-location@r{, @code{msgfilter} option} 156Generate @samp{#: @var{filename}:@var{line}} lines (default). 157 158@item --strict 159@opindex --strict@r{, @code{msgfilter} option} 160Write out a strict Uniforum conforming PO file. Note that this 161Uniforum format should be avoided because it doesn't support the 162GNU extensions. 163 164@item -p 165@itemx --properties-output 166@opindex -p@r{, @code{msgfilter} option} 167@opindex --properties-output@r{, @code{msgfilter} option} 168Write out a Java ResourceBundle in Java @code{.properties} syntax. Note 169that this file format doesn't support plural forms and silently drops 170obsolete messages. 171 172@item --stringtable-output 173@opindex --stringtable-output@r{, @code{msgfilter} option} 174Write out a NeXTstep/GNUstep localized resource file in @code{.strings} syntax. 175Note that this file format doesn't support plural forms. 176 177@item -w @var{number} 178@itemx --width=@var{number} 179@opindex -w@r{, @code{msgfilter} option} 180@opindex --width@r{, @code{msgfilter} option} 181Set the output page width. Long strings in the output files will be 182split across multiple lines in order to ensure that each line's width 183(= number of screen columns) is less or equal to the given @var{number}. 184 185@item --no-wrap 186@opindex --no-wrap@r{, @code{msgfilter} option} 187Do not break long message lines. Message lines whose width exceeds the 188output page width will not be split into several lines. Only file reference 189lines which are wider than the output page width will be split. 190 191@item -s 192@itemx --sort-output 193@opindex -s@r{, @code{msgfilter} option} 194@opindex --sort-output@r{, @code{msgfilter} option} 195Generate sorted output. Note that using this option makes it much harder 196for the translator to understand each message's context. 197 198@item -F 199@itemx --sort-by-file 200@opindex -F@r{, @code{msgfilter} option} 201@opindex --sort-by-file@r{, @code{msgfilter} option} 202Sort output by file location. 203 204@end table 205 206@subsection Informative output 207 208@table @samp 209@item -h 210@itemx --help 211@opindex -h@r{, @code{msgfilter} option} 212@opindex --help@r{, @code{msgfilter} option} 213Display this help and exit. 214 215@item -V 216@itemx --version 217@opindex -V@r{, @code{msgfilter} option} 218@opindex --version@r{, @code{msgfilter} option} 219Output version information and exit. 220 221@end table 222 223@subsection Examples 224 225To convert German translations to Swiss orthography (in an UTF-8 locale): 226 227@smallexample 228msgconv -t UTF-8 de.po | msgfilter sed -e 's/@ss{}/ss/g' 229@end smallexample 230 231To convert Serbian translations in Cyrillic script to Latin script: 232 233@smallexample 234msgfilter recode-sr-latin sr.po 235@end smallexample 236