feat: python extractor
This commit is contained in:
parent
e212cad44e
commit
6c4184afc2
3 changed files with 13 additions and 0 deletions
0
frappe/gettext/__init__.py
Normal file
0
frappe/gettext/__init__.py
Normal file
0
frappe/gettext/extractors/__init__.py
Normal file
0
frappe/gettext/extractors/__init__.py
Normal file
13
frappe/gettext/extractors/python.py
Normal file
13
frappe/gettext/extractors/python.py
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
from babel.messages.extract import extract_python
|
||||||
|
|
||||||
|
|
||||||
|
def extract(*args, **kwargs):
|
||||||
|
"""
|
||||||
|
Wrapper around babel's `extract_python`, handling our own implementation of `_()`
|
||||||
|
"""
|
||||||
|
for lineno, funcname, messages, comments in extract_python(*args, **kwargs):
|
||||||
|
if funcname == "_" and isinstance(messages, tuple) and len(messages) > 1:
|
||||||
|
funcname = "pgettext"
|
||||||
|
messages = (messages[-1], messages[0]) # (context, message)
|
||||||
|
|
||||||
|
yield lineno, funcname, messages, comments
|
||||||
Loading…
Add table
Reference in a new issue