-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extract: "Deeply nested" gettext calls aren't extracted #1125
Comments
dylankiss
added a commit
to dylankiss/babel
that referenced
this issue
Sep 19, 2024
Currently the Python extractor does not support deeply nested gettext calls (deeper than as a direct argument to the top-level gettext call). e.g. ```py _("Hello %s", _("Person")) _("Hello %s", random_function(", ".join([_("Person 1"), _("Person 2")]))) ``` The extraction code was refactored quite a bit to simplify the flow and support this use-case. Fixes python-babel#1125 (meanwhile also fixes python-babel#1123)
dylankiss
added a commit
to dylankiss/babel
that referenced
this issue
Oct 10, 2024
Currently the Python extractor does not support deeply nested gettext calls (deeper than as a direct argument to the top-level gettext call). e.g. ```py _("Hello %s", _("Person")) _("Hello %s", random_function(", ".join([_("Person 1"), _("Person 2")]))) ``` The extraction code was refactored quite a bit to simplify the flow and support this use-case. Fixes python-babel#1125 (meanwhile also fixes python-babel#1123)
dylankiss
added a commit
to dylankiss/babel
that referenced
this issue
Oct 17, 2024
Currently the Python extractor does not support deeply nested gettext calls (deeper than as a direct argument to the top-level gettext call). e.g. ```py _("Hello %s", _("Person")) _("Hello %s", random_function(", ".join([_("Person 1"), _("Person 2")]))) ``` The extraction code was refactored quite a bit to simplify the flow and support this use-case. Fixes python-babel#1125 (meanwhile also fixes python-babel#1123)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Overview
#488 enabled the
python
extractor to look at nested calls for strings to extract, but the way it does it ignores nested gettext calls when there's more than one level of nesting.This is because scanning sources for nested calls is only done when
call_stack
is 0:babel/babel/messages/extract.py
Lines 554 to 555 in f91754b
call_stack
starts at -1, and is incremented each time an opening parenthesis is encountered within a gettext call:babel/babel/messages/extract.py
Lines 526 to 534 in f91754b
In the case of a "deeply nested" call (a call with more than one level of nesting), the value of
call_stack
will be greater than 0, meaning that the part of the code that handles the nested call will never be reached, and the contents of that call won't be exported.Steps to Reproduce
Copy-paste this to your python REPL:
Actual Results
"deeply nested call" is missing.
Note: the lineno of "dummy" is also wrong, see this other issue.
Expected Results
The text was updated successfully, but these errors were encountered: