Closed ldaverio closed 9 years ago
Lingua should not abort like that, but I don't see how it could ever handling something like _other(foo("Bug!"))
: there is no way for lingua to know what foo()
will do and what it returns. The best I can do is fix the parser to not abort like this, but it will never do what you might want here.
Considering that Python 3.3 and later support u"..."
I would strongly suggest to just use that and not use six.u(..)
or an alternative for this kind of usage.
Hi :) My post was not about the extractor ignoring embedded function calls, which is normal, but specifically about crashing on _other(foo("Bug!"))
.
I'm not too familiar with Python 3 yet, so I figured that using Modernize was a good idea. But now I can see it isn't, and I'm going to follow your advice. Thank you!
PS: Actually, with Lingua 1.6, I had modified the extractor to take six.u()
into account inside translator functions. It was an ugly hack, and I'm glad I can get rid of it :)
After upgrading from Lingua 1.6 to 3.9, and trying
pot-create
with an existing project, I came across a bug in the Python extractor. Some of the files of the projects had been processed by Modernize (https://pypi.python.org/pypi/modernize), and Unicode strings had been rewritten assix.u("...")
.If a custom translation function is used on such "strings" (e.g.
_other(...)
instead of_(...)
), the extractor will choke with the following error message:The error can be reproduced by running
pot-create --keyword=_other x.py
on the following Python code. It will correctly handle lines 1-3, but choke on line 4: