Closed tisdall closed 10 years ago
Looks like 2.5 broke the Babel plugin handling :(. I'll look into that tomorrow.
The exception I got on 2.4, was that something I was doing wrong or something that's been fixed in 2.5?
I am guessing the Babel plugin API uses strings for comments instead of a list of strings, so the proxy-code in lingua needs to be modified to convert that. So lingua bug, not your fault.
Can you check if the current code in master works for you? Please note that the format of the configuration file has changed a bit.
# env/bin/pot-create -c lingua.cfg -o mainserver/locale/mainserver.pot mainserver
Traceback (most recent call last):
File "env/bin/pot-create", line 9, in <module>
load_entry_point('lingua==2.6dev', 'console_scripts', 'pot-create')()
File "/sites/repos/lingua/src/lingua/extract.py", line 253, in main
for message in extractor(real_filename, options):
File "/sites/repos/lingua/src/lingua/extractors/babel.py", line 28, in __call__
for (lineno, _, msgid, comment) in self.extractor(fileobj, DEFAULT_KEYWORDS.keys(), (), {}):
TypeError: extract() takes 4 positional arguments but 5 were given
lingua.cfg:
[extensions]
.mako = babel-mako
.pt = chameleon
.py = python
Does that change help?
# env/bin/pot-create -c lingua.cfg -o mainserver/locale/mainserver.pot mainserver
Traceback (most recent call last):
File "env/bin/pot-create", line 9, in <module>
load_entry_point('lingua==2.6dev', 'console_scripts', 'pot-create')()
File "/sites/repos/lingua/src/lingua/extract.py", line 268, in main
catalog.save(options.output)
File "/sites/metrics_dev/env/lib/python3.4/site-packages/polib.py", line 424, in save
contents = getattr(self, repr_method)()
File "/sites/metrics_dev/env/lib/python3.4/site-packages/polib.py", line 620, in __unicode__
return ret + _BaseFile.__unicode__(self)
File "/sites/metrics_dev/env/lib/python3.4/site-packages/polib.py", line 320, in __unicode__
ret.append(entry.__unicode__(self.wrapwidth))
File "/sites/metrics_dev/env/lib/python3.4/site-packages/polib.py", line 956, in __unicode__
val = getattr(self, c[0])
File "/sites/repos/lingua/src/lingua/extract.py", line 47, in tcomment
return u'\n'.join(self._tcomments)
TypeError: sequence item 0: expected str instance, NoneType found
Can you provide a sample mako file which triggers this error?
I just remembered I only have one file that I started adding translation markup into:
<%inherit file='layout.mako' />
<div class="col-md-12" id="maincontent">
% if failed_attempt:
<p><font color="red">${_('Invalid credentials, try again.')}</font></p>
% endif
<form method="post" action="${ request.route_path('login') }">
<p>
<label for="login">${_('Login')}</label><br>
<input type="text" name="login" value="${ login }" autocomplete="off">
</p>
<p>
<label for="passwd">${_('Password')}</label><br>
<input type="password" name="passwd" autocomplete="off">
</p>
<input type="hidden" name="next" value="${ next }">
<input type="submit" name="submit">
</form>
</div>
(Please excuse the font
tag... ^_^ I think this was cut-n-copied from an example.)
I pushed a few changes which makes the Babel-python plugin work for me. Does that fix your problems as well?
Success! Thank you!
... nearly. :) I tried adding comments as shown here: http://docs.makotemplates.org/en/latest/usage.html#babel I don't get any errors, but the comments aren't added to the POT file.
<%inherit file='layout.mako' />
<div class="col-md-12" id="maincontent">
% if failed_attempt:
<p><font color="red">
## TRANSLATORS: This is a proper name. See the gettext
## manual, section Names.
${_('Invalid credentials, try again.')}
</font></p>
% endif
<form method="post" action="${ request.route_path('login') }">
<p>
<label for="login">${_('Login')}</label><br>
<input type="text" name="login" value="${ login }" autocomplete="off">
</p>
<p>
<label for="passwd">${_('Password')}</label><br>
<input type="password" name="passwd" autocomplete="off">
</p>
<input type="hidden" name="next" value="${ next }">
<input type="submit" name="submit">
</form>
</div>
That sounds like a separate issue. The problem here is that you need to explicitly tell the mako plugin how to identify comments. With Babel's extract_messages you do that with the -c
option. With lingua you can do that (since the last change) through the configuration file:
[extensions]
.mako = babel-mako
[extractor:babel-mako]
comment-tags = TRANSLATORS:
Thanks for all the help!
FYI: there is a pull request for a mako lingua plugin now.
After updating to 2.5... (though it also didn't work in 2.4, but gave a different error)
I have a file
lingua.cfg
with contents:Then I try to use
pot-create
:prior to the update I got: