sqlalchemy / sqlalchemy/mako

Suggestion: Custom Python message extractor in the Babel plugin

Open
#136 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature low priority runtime
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.