You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the heels of #71 and #296 I decdied to document some of the oddities I ecnountered when using pybabel CLI.
This is the test dist/gettext.js file I'm using
var x = __("sing")
var z = __n("sing1", "plu1")
var y = __n("sing2", "plu2", 10)
var zzz = _("aaa")
1. pybabel extract ignores babel.cfg (docs are incorrect?)
According to docs, babel.cfg should look like this:
[javascript: **.js]
extract_messages = __
Run:
$ pybabel extract -F ./babel.cfg -o dist/lang/en.pot ./dist/gettext.js
extracting messages from ./dist/gettext.js (extract_messages="__")
writing PO template file to dist/lang/en.pot
It will only extract messages surrounded by _() (single underscore)
2. Ignores keywords in babel.cfg
Google + friends suggest that this is the correct babel.cfg:
[javascript: **.js]
keywords = __
Run:
$ pybabel extract -F ./babel.cfg -o dist/lang/en.pot ./dist/gettext.js
extracting messages from ./dist/gettext.js (keywords="__")
writing PO template file to dist/lang/en.pot
Result: only messages surrounded by _() are extracted (single underscore)
3. pybabel extract ignores -keywords parameter
Run $ pybabel extract --keywords=__ -o dist/lang/en.pot ./dist/gettext.js writing PO template file to dist/lang/en.pot
Result: no strings are extracted
4. pybabel extract requires babel.cfg even though it ignores its settings
Given the babel.cfg from above, run:
$ pybabel extract -F ./babel.cfg --keywords=__ -o dist/lang/en.pot ./dist/gettext.js
extracting messages from ./dist/gettext.js (keywords="__")
writing PO template file to dist/lang/en.pot
Result: strings are extracted for both _() and __()
5. pybabel extract requires babel.cfg even though it ignores its settings and complains about keywords not being set
Basically an extension of the above. Remove --keywords and add --no-default-keywords:
$ pybabel extract -F ./babel.cfg --no-default-keywords -o dist/lang/en.pot ./dist/gettext.js
Usage: pybabel extract [options] <input-paths>
pybabel: error: you must specify new keywords if you disable the default ones
Summary:
Please make one of the following:
make sure Babel CLI respects settings in babel.cfg, or
add a command-line parameter to babel extract to let it extract from .js files without the need for babel.cfg
The text was updated successfully, but these errors were encountered:
On the heels of #71 and #296 I decdied to document some of the oddities I ecnountered when using pybabel CLI.
This is the test
dist/gettext.js
file I'm using1.
pybabel extract
ignoresbabel.cfg
(docs are incorrect?)According to docs,
babel.cfg
should look like this:Run:
It will only extract messages surrounded by
_()
(single underscore)2. Ignores
keywords
inbabel.cfg
Google + friends suggest that this is the correct
babel.cfg
:Run:
Result: only messages surrounded by
_()
are extracted (single underscore)3.
pybabel extract
ignores-keywords
parameterRun
$ pybabel extract --keywords=__ -o dist/lang/en.pot ./dist/gettext.js writing PO template file to dist/lang/en.pot
Result: no strings are extracted
4.
pybabel extract
requiresbabel.cfg
even though it ignores its settingsGiven the
babel.cfg
from above, run:Result: strings are extracted for both
_()
and__()
5.
pybabel extract
requiresbabel.cfg
even though it ignores its settings and complains about keywords not being setBasically an extension of the above. Remove
--keywords
and add--no-default-keywords
:Summary:
Please make one of the following:
babel.cfg
, orbabel extract
to let it extract from.js
files without the need forbabel.cfg
The text was updated successfully, but these errors were encountered: