bug report: pylupdate corrupts ampersand symbols

Efrem Braun efrem.braun at gmail.com
Thu Jan 27 16:12:59 GMT 2022


Sure.

1. Take form.ui (which I made in Qt Creator), which has a red label (which
Qt Creator produces by using HTML formatting).
2. Run `pyuic5 -x form.ui -o form.py` to create form.py.
3. Run `pylupdate5 main.pro` to create ja_JP.ts.
4. Open ja_JP.ts in Qt Linguist, and provide a translation of the source
text "<html><head/><body><p><span style=" color:#ff0000;">Colored
Label</span></p></body></html>" to "<html><head/><body><p><span style="
color:#ff0000;">Translated Colored Label</span></p></body></html>". Save
the ja_JP.ts file in Qt Linguist.
5. Run `pylupdate5 main.pro` to update ja_JP.ts.
6. Open ja_JP.ts and you will see the ampersand symbols.

Efrem Braun


On Thu, Jan 27, 2022 at 10:33 AM Phil Thompson <phil at riverbankcomputing.com>
wrote:

> On 25/01/2022 15:06, Efrem Braun wrote:
> > Since updating my PyQt5 from version 5.15.4 to PySide6 (and I've
> > confirmed
> > that this issue is also present in 5.15.5, so the issue originated
> > there),
> > ampersand symbols in the existing .ts files have begun being replaced
> > by
> > "&amp", even when the ampersand symbols are being used as escape
> > characters. This occurs in the "translation" lines only, not the
> > "source"
> > lines. This is an issue when HTML formatting is used.
> >
> > For example, I used to have an entry:
> > ```
> >     <message>
> >         <location
> > filename="../../xslide-desktop/xslide_desktop/views/Ui_MainWindow.py"
> > line="2655"/>
> >
> > <source><html><head/><body><p>Background
> > File
> > <br>
> > (optional)</p></body></html></source>
> >
> > <translation><html><head/><body><p>バックグラウンドファイル
> > <br>
> > (任意)</p></body></html></translation>
> >     </message>
> > ```
> >
> > It now gets replaced by:
> >
> > ```
> >     <message>
> >         <location
> > filename="../../xslide-desktop/xslide_desktop/views/Ui_MainWindow.py"
> > line="2655"/>
> >
> > <source><html><head/><body><p>Background
> > File
> > <br>
> > (optional)</p></body></html></source>
> >         <translation
> >
> type="obsolete">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;バックグラウンドファイル
> > &lt;br&gt;
> >
> (任意)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
> >     </message>
> > ```
> >
> > After converting this to the .qm file and running the application, the
> > translation shows up in my application with the html code.
> >
> > To workaround this, I'm using pylupdate5 from version 5.15.4 to
> > generate my
> > translation files. But obviously it'd be nicer to use the latest
> > version.
> >
> > Efrem Braun
>
> I'm struggling to reproduce this. Can you give me the *exact* steps you
> took and attach a short .py source file?
>
> Phil
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220127/d8f291bb/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.pro
Type: application/octet-stream
Size: 42 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220127/d8f291bb/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ja_JP.ts
Type: application/octet-stream
Size: 868 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220127/d8f291bb/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: form.py
Type: text/x-python-script
Size: 1823 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220127/d8f291bb/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: form.ui
Type: application/octet-stream
Size: 1132 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220127/d8f291bb/attachment-0002.obj>


More information about the PyQt mailing list