report_msg_content(msg,
cat,
wrapf=None,
force=False,
note=None,
delim=None,
highlight=None,
showmsg=True,
fmsg=None,
showfmsg=False,
subsrc=None,
file=sys.stdout)
|
|
Report the content of a PO message.
Provides the message reference, consisting of the catalog name and the
message position within it, the message contents, and any notes on
particular segments.
Parts of the message can be highlighted using colors. Parameter
highlight provides the highlighting specification, as list
of tuples where each tuple consists of: name of the message element to
highlight, element index (used when the element is a list of values),
list of spans, and optionally the filtered text of the element value. For
example, to highlight spans (5, 10) and (15,
25) in the msgid , and (30, 40) in
msgstr , the highlighting specification would be:
[("msgid", 0, [(5, 10), (15, 25)]), ("msgstr", 0, [(30, 40)])]
Names of the elements that can presently be highlighted are:
"msgctxt" , "msgid" ,
"msgid_plural" , "msgstr" ,
"manual_comment" ,
"auto_comment" , "source" ,
"flag" . For unique fields the element index is not
used, but 0 should be given for consistency (may be enforced later). Span
tuples can have a third element, following the indices, which is the note
about why the particular span is highlighted; there may be more elements
after the note, and these are all ignored. If start or end index of a
span is not an integer, then the note is taken as relating to the
complete field.
Sometimes the match to which the spans correspond has been made on a
filtered value of the message field (e.g. after accelerator markers or
tags have been removed). In that case, the filtered text can be given as
the fourth element of the tuple, after the list of spans, and the
function will try to fit spans from filtered onto original text. More
globally, if the complete highlight is relative to a modified, filtered
version of the message, this message can be given as fmsg
parameter.
The display of content can be controlled by showmsg
parameter; if it is False , only the message reference and
span notes are shown. Similarly for the showfmsg parameter,
which controls the display of the content of filtered message (if given
by fmsg ). To show the filtered message may be useful for
debugging filtering in cases when it is not straightforward, or it is
user-defined.
- Parameters:
msg (Message_base) - the message to report the content for
cat (Catalog or None ) - the catalog where the message lives
wrapf ((string)->[string...]) - the function used for wrapping message fields in output. See to_lines() method of message classes for
details. If not given, it will be taken from the catalog (see Catalog.wrapf).
force (bool) - whether to force reformatting of cached message content
note (string) - note about why the content is being reported
delim (None or string) - text to print on the line following the message
highlight ((see description)) - highlighting specification of message elements
showmsg (bool) - show content of the message
fmsg (Message_base) - filtered message
showfmsg (bool) - show content of the filtered message, if any
subsrc (None or string) - more detailed source of the message
file (file) - output stream
|