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