pylupdate6: cannot parse python files without directly referencing module name
Phil Thompson
phil at riverbankcomputing.com
Wed Jul 5 18:00:39 BST 2023
On 30/06/2023 08:32, Albin Söderqvist wrote:
> 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
I assume you mean...
translate = QCoreApplication.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.
Fixed in the next snapshot.
Phil
More information about the PyQt
mailing list