Open sqlalchemy-bot opened 14 years ago
Philip Jenvey (@pjenvey) wrote:
I'm really curious about the modifications you've done to extract_python. Before I consider this, could you tell me what customizations you've done?
Anonymous wrote:
Sure. I've simplified the gettext API to only use one function instead of ugettext/ungettext, with keyword arguments. It also handles translation context (like GTK's Q() macro). So the function has the signature: def (message, plural=None, n=None, context=None)
Some examples:[[BR]] ('file') calls ugettext[[BR]] ('%s file', '%s files', n=3) calls ungettext[[BR]] ('file', context='noun') can have different translation than ('file', context='verb')
Babel's Python extractor can't handle keyword arguments, so another one is needed. My extractor currently compiles the code to AST and analyzes that.
Changes by Philip Jenvey (@pjenvey):
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:
and then calling
extractor
instead ofextract_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):
and call
babel_extract(method, ...)
instead ofextract_python(...)
(Sorry for filing this under the "runtime" component, it doesn't fit in any of the available ones.)