-
Notifications
You must be signed in to change notification settings - Fork 447
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
Allow extractors to provide message flags #838
base: master
Are you sure you want to change the base?
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.
Let me know if this PR has any future and if so I'll clean it up, fix the last remaining tests and add a few new tests. Based on this I also have working code fixing #759, support for the python-brace-format flag :) Edit: And I just noticed #80 🙈 That makes the same changes to the interface, but it doesn't appear to implement the flag detection bit in the Python extractor, which would be yet another breaking change when using the Anyway, let me know if you want me to get this over the finish line. We might be switching over to Babel for a project at work, so I need these changes and will probably maintain a fork until this is fixed (we need python-brace-format detection as well, hence why I started on this). |
Building upon python-babel#838, this adds support for python-brace-format flags in the python extractor. Fixes python-babel#333
Building upon python-babel#838, this adds support for python-brace-format flags in the python extractor. Fixes python-babel#333
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 feature would still be great! |
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