demangle_srcrefs(collsrcs=None,
collsrcmap=None,
truesrcheads=None,
compexts=None)
|
|
Resolve source references in message created by intermediate
extraction [hook factory].
Sometimes the messages from a source file in the format not known to
xgettext(1) are first extracted by a preextraction tool into
a format known to xgettext , and then by
xgettext to PO template. This is the intermediate
extraction, and the files that xgettext gets to operate on
are intermediate files.
When intermediate extraction is performed, the source references in
the resulting PO template are going to be "mangled", pointing
to the intermediate files rather than to the true source files. This hook
factory will produce a function that will resolve intermediate into true
source reference, "demangle" them, where possible.
One mode of intermediate extraction is to extract multiple sources
into a collective intermediate file. This file may have standardized name
throughout a collection of catalogs, or it may be special by catalog. For
demangling to be possible in this case, the preextraction tool has to
provide true source references in the extracted comments
(#. ) of the messages. When that is the case, parameter
collsrcs is used to specify the sequence of names of
generally known intermediate files, parameter collsrcmap of
those specific by catalog (as dictionary of catalog name to sequence of
intermediate file names), and parameter truesrcheads
specifies the sequence of initial strings in extracted comments which are
followed by the true source reference. (If truesrcheads is
None or empty, this mode of demangling is disabled.)
For example, collective-intermediate extraction:
#. file: apples.clt:156
#: resources.cpp:328
msgid "Granny Smith"
msgstr ""
#. file: peaches.clt:49
#: resources.cpp:2672
msgid "Redhaven"
msgstr ""
is demangled by setting
collsrcs=["resources.cpp"] and
truesrcheads=["file:"] .
Another mode of intermediate extraction is to for each source file to
be extracted into a single paired intermediate file, which is named same
as the true source plus an additional extension. In this mode, parameter
compexts specifies the list of known composite extensions
(including the leading dot), which will be demangled by stripping the
final extension from the path.
For example, paired-intermediate extraction:
#: apples.clt.h:156
msgid "Granny Smith"
msgstr ""
#: peaches.clt.h:49
msgid "Redhaven"
msgstr ""
is demangled by setting
compexts=[".clt.h"] .
- Parameters:
collsrcs (<string*>) - general intermediate file names
collsrcmap ({string: <string*>*}) - catalog-specific intermediate file names
truesrcheads (<string*>) - prefixes to true file references in comments
compexts (<string*>) - composite intermediate file extensions
- Returns:
(cat, msg) -> numerr
- type F4A hook
|