Skip to content

Ignore strings inside subscripts when extracting messages - #1367

Open
Kayvan-Zahiri wants to merge 1 commit into
python-babel:masterfrom
Kayvan-Zahiri:fix/extractor-ignore-subscript-strings-1335
Open

Kayvan-Zahiri wants to merge 1 commit into
python-babel:masterfrom
Kayvan-Zahiri:fix/extractor-ignore-subscript-strings-1335

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Fixes #1335.

pgettext(context, dictionary["key"]) extracted "key". A dict literal in the same position was extracted too ({"msgid": "value"} became msgidvalue). Those strings are not arguments of the call.

Strings inside [] or {} are skipped. A nested gettext() call is still extracted, and pgettext("navigation", "Guide") is unchanged.

Tests: PYTHONPATH=. python -m pytest --noconftest -o addopts= tests/messages/test_extract.py -q → 12 passed. Before the fix, the new test extracted key and msgidvalue.

Made with Cursor

pgettext(context, dictionary["key"]) treated the subscript key as
the message. Strings inside brackets or braces are not arguments.

Co-authored-by: Cursor <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python extractor treats dict arguments as literal strings

1 participant