Suggestion: Custom Python message extractor in the Babel plugin
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 459
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
Migrated issue, originally created by Anonymous
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.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in mako.ext.babelplugin:extract_nodes and compare its direct use of extract_python with the proposed Babel extraction options. Done means a caller can select a custom Python message extractor while the existing default behavior remains available; check the surrounding Babel plugin code for relevant verification points.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- localization
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100