1@pindex msggrep 2@cindex @code{msggrep} program, usage 3@example 4msggrep [@var{option}] [@var{inputfile}] 5@end example 6 7@cindex search messages in a catalog 8The @code{msggrep} program extracts all messages of a translation catalog 9that match a given pattern or belong to some given source files. 10 11@subsection Input file location 12 13@table @samp 14@item @var{inputfile} 15Input PO file. 16 17@item -D @var{directory} 18@itemx --directory=@var{directory} 19@opindex -D@r{, @code{msggrep} option} 20@opindex --directory@r{, @code{msggrep} option} 21Add @var{directory} to the list of directories. Source files are 22searched relative to this list of directories. The resulting @file{.po} 23file will be written relative to the current directory, though. 24 25@end table 26 27If no @var{inputfile} is given or if it is @samp{-}, standard input is read. 28 29@subsection Output file location 30 31@table @samp 32@item -o @var{file} 33@itemx --output-file=@var{file} 34@opindex -o@r{, @code{msggrep} option} 35@opindex --output-file@r{, @code{msggrep} option} 36Write output to specified file. 37 38@end table 39 40The results are written to standard output if no output file is specified 41or if it is @samp{-}. 42 43@subsection Message selection 44 45@example 46 [-N @var{sourcefile}]... [-M @var{domainname}]... 47 [-J @var{msgctxt-pattern}] [-K @var{msgid-pattern}] [-T @var{msgstr-pattern}] 48 [-C @var{comment-pattern}] 49@end example 50 51A message is selected if 52@itemize @bullet 53@item it comes from one of the specified source files, 54@item or if it comes from one of the specified domains, 55@item or if @samp{-J} is given and its context (msgctxt) matches 56 @var{msgctxt-pattern}, 57@item or if @samp{-K} is given and its key (msgid or msgid_plural) matches 58 @var{msgid-pattern}, 59@item or if @samp{-T} is given and its translation (msgstr) matches 60 @var{msgstr-pattern}, 61@item or if @samp{-C} is given and the translator's comment matches 62 @var{comment-pattern}. 63@end itemize 64 65When more than one selection criterion is specified, the set of selected 66messages is the union of the selected messages of each criterion. 67 68@var{msgctxt-pattern} or @var{msgid-pattern} or @var{msgstr-pattern} syntax: 69@example 70 [-E | -F] [-e @var{pattern} | -f @var{file}]... 71@end example 72@var{pattern}s are basic regular expressions by default, or extended regular 73expressions if -E is given, or fixed strings if -F is given. 74 75@table @samp 76@item -N @var{sourcefile} 77@itemx --location=@var{sourcefile} 78@opindex -N@r{, @code{msggrep} option} 79@opindex --location@r{, @code{msggrep} option} 80Select messages extracted from @var{sourcefile}. @var{sourcefile} can be 81either a literal file name or a wildcard pattern. 82 83@item -M @var{domainname} 84@itemx --domain=@var{domainname} 85@opindex -M@r{, @code{msggrep} option} 86@opindex --domain@r{, @code{msggrep} option} 87Select messages belonging to domain @var{domainname}. 88 89@item -J 90@itemx --msgctxt 91@opindex -J@r{, @code{msggrep} option} 92@opindex --msgctxt@r{, @code{msggrep} option} 93Start of patterns for the msgctxt. 94 95@item -K 96@itemx --msgid 97@opindex -K@r{, @code{msggrep} option} 98@opindex --msgid@r{, @code{msggrep} option} 99Start of patterns for the msgid. 100 101@item -T 102@itemx --msgstr 103@opindex -T@r{, @code{msggrep} option} 104@opindex --msgstr@r{, @code{msggrep} option} 105Start of patterns for the msgstr. 106 107@item -C 108@itemx --comment 109@opindex -C@r{, @code{msggrep} option} 110@opindex --comment@r{, @code{msggrep} option} 111Start of patterns for the translator's comment. 112 113@item -X 114@itemx --extracted-comment 115@opindex -X@r{, @code{msggrep} option} 116@opindex --extracted-comment@r{, @code{msggrep} option} 117Start of patterns for the extracted comments. 118 119@item -E 120@itemx --extended-regexp 121@opindex -E@r{, @code{msggrep} option} 122@opindex --extended-regexp@r{, @code{msggrep} option} 123Specify that @var{pattern} is an extended regular expression. 124 125@item -F 126@itemx --fixed-strings 127@opindex -F@r{, @code{msggrep} option} 128@opindex --fixed-strings@r{, @code{msggrep} option} 129Specify that @var{pattern} is a set of newline-separated strings. 130 131@item -e @var{pattern} 132@itemx --regexp=@var{pattern} 133@opindex -e@r{, @code{msggrep} option} 134@opindex --regexp=@r{, @code{msggrep} option} 135Use @var{pattern} as a regular expression. 136 137@item -f @var{file} 138@itemx --file=@var{file} 139@opindex -f@r{, @code{msggrep} option} 140@opindex --file@r{, @code{msggrep} option} 141Obtain @var{pattern} from @var{file}. 142 143@item -i 144@itemx --ignore-case 145@opindex -i@r{, @code{msggrep} option} 146@opindex --ignore-case@r{, @code{msggrep} option} 147Ignore case distinctions. 148 149@item -v 150@itemx --invert-match 151@opindex -v@r{, @code{msggrep} option} 152@opindex --invert-match@r{, @code{msggrep} option} 153Output only the messages that do not match any selection criterion, instead 154of the messages that match a selection criterion. 155 156@end table 157 158@subsection Input file syntax 159 160@table @samp 161@item -P 162@itemx --properties-input 163@opindex -P@r{, @code{msggrep} option} 164@opindex --properties-input@r{, @code{msggrep} option} 165Assume the input file is a Java ResourceBundle in Java @code{.properties} 166syntax, not in PO file syntax. 167 168@item --stringtable-input 169@opindex --stringtable-input@r{, @code{msggrep} option} 170Assume the input file is a NeXTstep/GNUstep localized resource file in 171@code{.strings} syntax, not in PO file syntax. 172 173@end table 174 175@subsection Output details 176 177@c --no-escape and --escape omitted on purpose. They are not useful. 178 179@table @samp 180@item --force-po 181@opindex --force-po@r{, @code{msggrep} option} 182Always write an output file even if it contains no message. 183 184@item --indent 185@opindex --indent@r{, @code{msggrep} option} 186Write the .po file using indented style. 187 188@item --no-location 189@opindex --no-location@r{, @code{msggrep} option} 190Do not write @samp{#: @var{filename}:@var{line}} lines. 191 192@item --add-location 193@opindex --add-location@r{, @code{msggrep} option} 194Generate @samp{#: @var{filename}:@var{line}} lines (default). 195 196@item --strict 197@opindex --strict@r{, @code{msggrep} option} 198Write out a strict Uniforum conforming PO file. Note that this 199Uniforum format should be avoided because it doesn't support the 200GNU extensions. 201 202@item -p 203@itemx --properties-output 204@opindex -p@r{, @code{msggrep} option} 205@opindex --properties-output@r{, @code{msggrep} option} 206Write out a Java ResourceBundle in Java @code{.properties} syntax. Note 207that this file format doesn't support plural forms and silently drops 208obsolete messages. 209 210@item --stringtable-output 211@opindex --stringtable-output@r{, @code{msggrep} option} 212Write out a NeXTstep/GNUstep localized resource file in @code{.strings} syntax. 213Note that this file format doesn't support plural forms. 214 215@item -w @var{number} 216@itemx --width=@var{number} 217@opindex -w@r{, @code{msggrep} option} 218@opindex --width@r{, @code{msggrep} option} 219Set the output page width. Long strings in the output files will be 220split across multiple lines in order to ensure that each line's width 221(= number of screen columns) is less or equal to the given @var{number}. 222 223@item --no-wrap 224@opindex --no-wrap@r{, @code{msggrep} option} 225Do not break long message lines. Message lines whose width exceeds the 226output page width will not be split into several lines. Only file reference 227lines which are wider than the output page width will be split. 228 229@item --sort-output 230@opindex --sort-output@r{, @code{msggrep} option} 231Generate sorted output. Note that using this option makes it much harder 232for the translator to understand each message's context. 233 234@item --sort-by-file 235@opindex --sort-by-file@r{, @code{msggrep} option} 236Sort output by file location. 237 238@end table 239 240@subsection Informative output 241 242@table @samp 243@item -h 244@itemx --help 245@opindex -h@r{, @code{msggrep} option} 246@opindex --help@r{, @code{msggrep} option} 247Display this help and exit. 248 249@item -V 250@itemx --version 251@opindex -V@r{, @code{msggrep} option} 252@opindex --version@r{, @code{msggrep} option} 253Output version information and exit. 254 255@end table 256 257@subsection Examples 258 259To extract the messages that come from the source files 260@code{gnulib-lib/error.c} and @code{gnulib-lib/getopt.c}: 261 262@smallexample 263msggrep -N gnulib-lib/error.c -N gnulib-lib/getopt.c input.po 264@end smallexample 265 266To extract the messages that contain the string ``Please specify'' in the 267original string: 268 269@smallexample 270msggrep --msgid -F -e 'Please specify' input.po 271@end smallexample 272 273To extract the messages that have a context specifier of either ``Menu>File'' 274or ``Menu>Edit'' or a submenu of them: 275 276@smallexample 277msggrep --msgctxt -E -e '^Menu>(File|Edit)' input.po 278@end smallexample 279 280To extract the messages whose translation contains one of the strings in the 281file @code{wordlist.txt}: 282 283@smallexample 284msggrep --msgstr -F -f wordlist.txt input.po 285@end smallexample 286