pylupdate6: cannot parse python files without directly referencing module name
Albin Söderqvist
albin.soderqvist at hostmobility.com
Fri Jun 30 08:32:29 BST 2023
Hi,
I'm unable to extract strings for translation using pylupdate6 without
calling QCoreApplication.translate each time. With pylupdate5, I can
import translation (or import translation as som_other_name) which is
convenient.
$ cat bug.py
from PyQt6.QtCore import QCoreApplication
from QCoreApplication import translate
a = translate("Bugs", "Can parse this with pylupdate5 but not
pylupdate6 (<= 6.5.1)")
b = QCoreApplication.translate("Bugs", "Can parse this with both v5 and
v6")
$ pylupdate6 bug.py -ts translation_template.ts
Summary of changes to translation_template.ts:
1 new messages were added
$ cat translation_template.ts
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>Bugs</name>
<message>
<location filename="bug.py" line="7" />
<source>Can parse this with both v5 and v6</source>
<translation type="unfinished" />
</message>
</context>
</TS>
$ rm translation_template.ts
$ pylupdate5 bug.py -ts translation_template.ts
$ cat translation_template.ts
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>Bugs</name>
<message>
<location filename="bug.py" line="7"/>
<source>Can parse this with both v5 and v6</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="bug.py" line="6"/>
<source>Can parse this with pylupdate5 but not pylupdate6
(<= 6.5.1)</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
I don't have this issue with .ui files.
---
Albin Söderqvist
More information about the PyQt
mailing list