[PyQt] pylupdate5 doesn't find all translations

Phil Thompson phil at riverbankcomputing.com
Sun Nov 13 01:07:34 GMT 2016


On 13 Nov 2016, at 12:46 am, Hans-Peter Jansen <hpj at urpla.net> wrote:
> 
> Hi Phil,
>  
> here's an excerpt, where the second translation is missing in the resulting ts:
>  
> test.py:
> #-*- coding: utf-8 -*-
>  
> from PyQt5.QtCore import QCoreApplication
> from PyQt5.QtWidgets import QMessageBox
>  
> def ErrorReport(cfg, msg):
>     _translate = QCoreApplication.translate
>  
>     msgBox = QMessageBox(QMessageBox.Critical,
>                          _translate("ErrorReport", "Oops"),
>                          _translate("ErrorReport", "<h3>An unexpected {0} exception has "
>         "been occured:</h3><pre><font face='Bitstream Vera Sans Mono'>{1}\n</pre><br>"
>         "Please report this problem to: {2}".format(cfg.exc_type, msg, "me")))
>     msgBox.exec_()
>  
> $ pylupdate5 test.py -ts test.ts
> $cat test.ts
> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE TS><TS version="2.0">
> <context>
>     <name>ErrorReport</name>
>     <message>
>         <location filename="test.py" line="9"/>
>         <source>Oops</source>
>         <translation type="unfinished"></translation>
>     </message>
> </context>
> </TS>
>  
> Is that to be expected?

You need to call the format() method of the value returned by _translate(), not the format() method of the string to be translated.

Phil



More information about the PyQt mailing list