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
babel.cfg keywords? #71
Comments
I found the same problem and after looking at the source I think I something is missing or I don't understand something. This is my babel.cfg [javascript:*.js]
encoding = utf-8
add_comments = TRANSLATORS:
keywords = npgettext,ifPlural in frontend.py in function parse_mapping babel.cfg is parsed. And you get out as expected: [('*.js', 'javascript')]
{'*.js': {'keywords': 'npgettext,ifPlural', 'add_comments': 'TRANSLATORS:', 'encoding': 'utf-8'}} Then we come to extract from dir function, which calles extract_from_file -> extract then extract_javascript is called. None of previously mentioned options didn't even touch options parsed from cfg file. And also in extract_javascript the only thing that is read from cfg is encoding. Interestingly in extract_python it is the same story. I tried to fix it so that I add "add_comments" key and "keywords" to comment_tags and keywords in extract_javascript. Adding to comment_tags worked. Adding to keywords didn't because you need parse_keywords function which is in fronted. So I think that in frontend.py or extract.py something is missing. |
@mitsuhiko have u looked at this? Would be nice if someone who knows the source would take a look at it. |
Two years later the issue is still here. According to the docs:
However, babel (specifically, CLI) ignores any values in In my case:
Then in
Then run babel:
Result:
If you change |
Ok. More weirdness. Babel CLI ignores
Babel CLI ignores this. But run it with
And here's the result. It extracted both
|
@scop @akx @mbirtwell Alerting you to this old/weird issue :) |
There still doesn't seem to be any way to specify keywords in the mapping file :( I'm considering duplicating the keywords in my extractor as both an option (specifiable in mapping file, not cli) and keywords (specifiable on cli, not mapping file), but it sounds like this would be very easy to support in Babel. |
This change was made because of bug in `pybabel` which we hit. python-babel/babel#71
This change was made because of bug in `pybabel` which we hit. python-babel/babel#71
This change was made because of bug in `pybabel` which we hit. python-babel/babel#71
I'm finding it hard to locate documentation on how to specify keywords in my
babel.cfg
. I have a config file that looks like this:All messages are extracted as expected except javascript. I've tried just setting one keyword in the config, changing the key from
keywords
toextract_messages
, andkeyword
but none seem to work. I've checked what keywords get passed tobabel.messages.extract.extract_javascript
(by simply doingsys.exit(keywords)
at the start of the function) and they never appear. However, doingpybabel extract -k translate -k ifPlural
works just fine.The text was updated successfully, but these errors were encountered: