Skip to content
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

pybabel extract: Extract pgettext with dynamic or default context (msgctxt) #902

Open
alex-kowalczyk opened this issue Aug 31, 2022 · 0 comments

Comments

@alex-kowalczyk
Copy link

Overview Description

Contexts are widely used nowadays to differentiate genders in messages. For instance:

pgettext(gender, "{user_name} followed you").format(user_name)

pybabel extract ignores extraction of context when it is not a fixed in-place string but variable.

Steps to Reproduce

echo 'pgettext(gender, "{username} followed you")' > test.py
pybabel extract test.py -o /dev/stdout

Actual Results

#: test.py:1
msgid "{username} followed you"
msgstr ""

Expected Results

At minimum, a placeholder msgctxt "" should be included, to allow for easy replicating of context permutations by postprocessing script.

Ideally, pybabel extract should accept a new --default-contexts parameter and generate proper permutations of the message. This would match the same feature for front-end code in i18Next extraction: https://i18next-extract.netlify.app/#/configuration?id=defaultcontexts

pybabel extract test.py -o /dev/stdout --default-contexts=male,female

#: test.py:1
msgctxt "male"
msgid "{username} followed you"
msgstr ""

#: test.py:1
msgctxt "female"
msgid "{username} followed you"
msgstr ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants