Quantcast
Channel: Mako: Ticket Query
Viewing all articles
Browse latest Browse all 38

#136: Suggestion: Custom Python message extractor in the Babel plugin

$
0
0

I use a gettext wrapper function with slightly modified semantics. I have written a Python message extractor for it, and now I would like to use the same extractor also in Mako. Would it be possible to specify the extract_python function to be should be used in mako.ext.babelplugin:extract_nodes ?

A simple solution would be along the lines of:

extractor = options.get('python_extract_function', extract_python)

and then calling extractor instead of extract_python directly.

Or, the babel.messages.extract:extract function could be called directly, for access to Babel's dispatching mechanism (with a slight backwards incompatibility):

from babel.messages.extract import extract as babel_extract
...
method = options.get('python_extractor', 'python')

and call babel_extract(method, ...) instead of extract_python(...)

(Sorry for filing this under the "runtime" component, it doesn't fit in any of the available ones.)


Viewing all articles
Browse latest Browse all 38

Trending Articles