gettext: msggrep Invocation
1
1 9.3 Invoking the ‘msggrep’ Program
1 ==================================
1
1 msggrep [OPTION] [INPUTFILE]
1
1 The ‘msggrep’ program extracts all messages of a translation catalog
1 that match a given pattern or belong to some given source files.
1
1 9.3.1 Input file location
1 -------------------------
1
1 ‘INPUTFILE’
1 Input PO file.
1
1 ‘-D DIRECTORY’
1 ‘--directory=DIRECTORY’
1 Add DIRECTORY to the list of directories. Source files are
1 searched relative to this list of directories. The resulting ‘.po’
1 file will be written relative to the current directory, though.
1
1 If no INPUTFILE is given or if it is ‘-’, standard input is read.
1
1 9.3.2 Output file location
1 --------------------------
1
1 ‘-o FILE’
1 ‘--output-file=FILE’
1 Write output to specified file.
1
1 The results are written to standard output if no output file is
1 specified or if it is ‘-’.
1
1 9.3.3 Message selection
1 -----------------------
1
1 [-N SOURCEFILE]... [-M DOMAINNAME]...
1 [-J MSGCTXT-PATTERN] [-K MSGID-PATTERN] [-T MSGSTR-PATTERN]
1 [-C COMMENT-PATTERN]
1
1 A message is selected if
1 • it comes from one of the specified source files,
1 • or if it comes from one of the specified domains,
1 • or if ‘-J’ is given and its context (msgctxt) matches
1 MSGCTXT-PATTERN,
1 • or if ‘-K’ is given and its key (msgid or msgid_plural) matches
1 MSGID-PATTERN,
1 • or if ‘-T’ is given and its translation (msgstr) matches
1 MSGSTR-PATTERN,
1 • or if ‘-C’ is given and the translator’s comment matches
1 COMMENT-PATTERN.
1
1 When more than one selection criterion is specified, the set of
1 selected messages is the union of the selected messages of each
1 criterion.
1
1 MSGCTXT-PATTERN or MSGID-PATTERN or MSGSTR-PATTERN syntax:
1 [-E | -F] [-e PATTERN | -f FILE]...
1 PATTERNs are basic regular expressions by default, or extended
1 regular expressions if -E is given, or fixed strings if -F is given.
1
1 ‘-N SOURCEFILE’
1 ‘--location=SOURCEFILE’
1 Select messages extracted from SOURCEFILE. SOURCEFILE can be
1 either a literal file name or a wildcard pattern.
1
1 ‘-M DOMAINNAME’
1 ‘--domain=DOMAINNAME’
1 Select messages belonging to domain DOMAINNAME.
1
1 ‘-J’
1 ‘--msgctxt’
1 Start of patterns for the msgctxt.
1
1 ‘-K’
1 ‘--msgid’
1 Start of patterns for the msgid.
1
1 ‘-T’
1 ‘--msgstr’
1 Start of patterns for the msgstr.
1
1 ‘-C’
1 ‘--comment’
1 Start of patterns for the translator’s comment.
1
1 ‘-X’
1 ‘--extracted-comment’
1 Start of patterns for the extracted comments.
1
1 ‘-E’
1 ‘--extended-regexp’
1 Specify that PATTERN is an extended regular expression.
1
1 ‘-F’
1 ‘--fixed-strings’
1 Specify that PATTERN is a set of newline-separated strings.
1
1 ‘-e PATTERN’
1 ‘--regexp=PATTERN’
1 Use PATTERN as a regular expression.
1
1 ‘-f FILE’
1 ‘--file=FILE’
1 Obtain PATTERN from FILE.
1
1 ‘-i’
1 ‘--ignore-case’
1 Ignore case distinctions.
1
1 ‘-v’
1 ‘--invert-match’
1 Output only the messages that do not match any selection criterion,
1 instead of the messages that match a selection criterion.
1
1 9.3.4 Input file syntax
1 -----------------------
1
1 ‘-P’
1 ‘--properties-input’
1 Assume the input file is a Java ResourceBundle in Java
1 ‘.properties’ syntax, not in PO file syntax.
1
1 ‘--stringtable-input’
1 Assume the input file is a NeXTstep/GNUstep localized resource file
1 in ‘.strings’ syntax, not in PO file syntax.
1
1 9.3.5 Output details
1 --------------------
1
1 ‘--color’
1 ‘--color=WHEN’
1 Specify whether or when to use colors and other text attributes.
1 See ⇒The --color option for details.
1
1 ‘--style=STYLE_FILE’
11 Specify the CSS style rule file to use for ‘--color’. See ⇒
The --style option for details.
1
1 ‘--force-po’
1 Always write an output file even if it contains no message.
1
1 ‘--indent’
1 Write the .po file using indented style.
1
1 ‘--no-location’
1 Do not write ‘#: FILENAME:LINE’ lines.
1
1 ‘-n’
1 ‘--add-location=TYPE’
1 Generate ‘#: FILENAME:LINE’ lines (default).
1
1 The optional TYPE can be either ‘full’, ‘file’, or ‘never’. If it
1 is not given or ‘full’, it generates the lines with both file name
1 and line number. If it is ‘file’, the line number part is omitted.
1 If it is ‘never’, it completely suppresses the lines (same as
1 ‘--no-location’).
1
1 ‘--strict’
1 Write out a strict Uniforum conforming PO file. Note that this
1 Uniforum format should be avoided because it doesn’t support the
1 GNU extensions.
1
1 ‘-p’
1 ‘--properties-output’
1 Write out a Java ResourceBundle in Java ‘.properties’ syntax. Note
1 that this file format doesn’t support plural forms and silently
1 drops obsolete messages.
1
1 ‘--stringtable-output’
1 Write out a NeXTstep/GNUstep localized resource file in ‘.strings’
1 syntax. Note that this file format doesn’t support plural forms.
1
1 ‘-w NUMBER’
1 ‘--width=NUMBER’
1 Set the output page width. Long strings in the output files will
1 be split across multiple lines in order to ensure that each line’s
1 width (= number of screen columns) is less or equal to the given
1 NUMBER.
1
1 ‘--no-wrap’
1 Do not break long message lines. Message lines whose width exceeds
1 the output page width will not be split into several lines. Only
1 file reference lines which are wider than the output page width
1 will be split.
1
1 ‘--sort-output’
1 Generate sorted output. Note that using this option makes it much
1 harder for the translator to understand each message’s context.
1
1 ‘--sort-by-file’
1 Sort output by file location.
1
1 9.3.6 Informative output
1 ------------------------
1
1 ‘-h’
1 ‘--help’
1 Display this help and exit.
1
1 ‘-V’
1 ‘--version’
1 Output version information and exit.
1
1 9.3.7 Examples
1 --------------
1
1 To extract the messages that come from the source files
1 ‘gnulib-lib/error.c’ and ‘gnulib-lib/getopt.c’:
1
1 msggrep -N gnulib-lib/error.c -N gnulib-lib/getopt.c input.po
1
1 To extract the messages that contain the string “Please specify” in
1 the original string:
1
1 msggrep --msgid -F -e 'Please specify' input.po
1
1 To extract the messages that have a context specifier of either
1 “Menu>File” or “Menu>Edit” or a submenu of them:
1
1 msggrep --msgctxt -E -e '^Menu>(File|Edit)' input.po
1
1 To extract the messages whose translation contains one of the strings
1 in the file ‘wordlist.txt’:
1
1 msggrep --msgstr -F -f wordlist.txt input.po
1