Wrong context detected by pylupdate
Giuseppe Corbelli <[email protected]> Wed, 24 Jun 2020 11:59:34 +0200
| Newsgroups | gmane.comp.python.pyqt-pykde |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------DC537D2C589F922244B84270
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=utf-8; format=flowed
Hi all
I found that under rather common circumstances pylupdate uses the wrong
context while generating TS files. I did not investigate much but I
expect trouble since the Qt tr() implementation uses
QMetaObject::className which is of course different.
Please see the attached test case and TS output.
pylupdate5 v5.15.0
Python 3.5.4
Linux, if it matters.
Yes, I know that Qt6 is on its way and pylupdate will be revamped. I
already found a workaround (do not define nested class) so it's no big
deal for me right now but maybe it's worth considering.
Thanks
--
Giuseppe Corbelli
--------------DC537D2C589F922244B84270
Content-Transfer-Encoding: 7bit
Content-Type: text/x-python; charset=UTF-8;
name="pylupdate_test.py"
Content-Disposition: attachment;
filename="pylupdate_test.py"
from PyQt5.QtCore import QObject, QCoreApplication
class A(QObject):
class B(QObject):
pass
def some_method(self):
self.tr("axs")
--------------DC537D2C589F922244B84270
Content-Transfer-Encoding: 7bit
Content-Type: text/vnd.qt.linguist; charset=UTF-8;
name="pylupdate_test.ts"
Content-Disposition: attachment;
filename="pylupdate_test.ts"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0">
<context>
<name>@default</name>
</context>
<context>
<name>B</name>
<message>
<location filename="pylupdate_test.py" line="19"/>
<source>axs</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
--------------DC537D2C589F922244B84270--