[PyQt] QCoreApplication.translate()

Phil Thompson phil at riverbankcomputing.com
Fri Jul 5 13:39:34 BST 2013


On Fri, 05 Jul 2013 13:46:43 +0200, paolo at paolodestefani.it wrote:
> Hi
> I'm trying to internationalize my PyQt application. Following the pyqt 
> reference guide i'm trying to use QCoreApplication.translate() instead 
> of self.tr().
> Works but only if i write the full function. But if i want to shorten 
> it in this way:
> 
> tr = QCoreApplication.translate
> 
> and then using
> 
> tr(contest, string, disambiguation)
> 
> it doesn't work ! I mean when i run pylupdate4.exe the created .ts file 
> is empty.
> If i change back using
> 
> QCoreApplication.translate(contest, string, disambiguation)
> 
> this works. The created .ts file is ok.
> 
> Why ? How can i use a short version of that function ? Is there another 
> way i can use that function ?
> 
> I look for an answer to this question using google but i found only 
> people with the same problem but no solution.
> Looks like an pylupdate4 issue.

pylupdate parses the Python source file. It can't know that you are using
a translation function with a different name.

Phil


More information about the PyQt mailing list