{{ message }}
Allow extractors to provide message flags#838
Draft
ljodal wants to merge 3 commits into
Draft
Conversation
This adds a sixth value to the tuple returned by the extractor functions which should be a set of flags. Which flags should be applied to a message should be determined by the extractor, as it depends on e.g. the file format being parsed. For example "%s" should have the python-format flag if it was parsed from a Python file and the c-format flag if it was extracted from a C file. The logic of detecting python-format flags is also moved to the Python extractor in this PR. NOTE: This is partially a breaking change. Backwards compability is maintained with extractors that return 5-tuples instead of 6-tuples, but the interface Babel exposes for extracting messages always returns 6-tuples. I don't see a good way around this. Removing the python-format detection from Message.__init__ is also a breaking change, but that could potentially be put back for now.
Contributor
Author
ljodal
added a commit
to ljodal/babel
that referenced
this pull request
Jan 31, 2022
Building upon python-babel#838, this adds support for python-brace-format flags in the python extractor. Fixes python-babel#333
ljodal
added a commit
to ljodal/babel
that referenced
this pull request
Feb 1, 2022
Building upon python-babel#838, this adds support for python-brace-format flags in the python extractor. Fixes python-babel#333
ljodal
added a commit
to ljodal/babel
that referenced
this pull request
Feb 1, 2022
Building upon python-babel#838, this adds support for python-brace-format flags in the python extractor. Fixes python-babel#333
|
I need this feature for custom extractor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This adds a sixth value to the tuple returned by the extractor functions
which should be a set of flags.
Which flags should be applied to a message should be determined by the
extractor, as it depends on e.g. the file format being parsed. For
example "%s" should have the python-format flag if it was parsed from a
Python file and the c-format flag if it was extracted from a C file.
The logic of detecting python-format flags is also moved to the Python
extractor in this PR.
NOTE:
This is partially a breaking change. Backwards compability is maintained
with extractors that return 5-tuples instead of 6-tuples, but the
interface Babel exposes for extracting messages always returns 6-tuples.
I don't see a good way around this.
Removing the python-format detection from Message.init is also a
breaking change, but that could potentially be put back for now.
Fixes #35