[PyQt] linguist skipping a line and missing context

Phil Thompson phil at riverbankcomputing.com
Sun Aug 23 14:56:16 BST 2009


On Sat, 22 Aug 2009 14:51:59 -0400, Paul Rouleau
<paul.rouleau at videotron.ca>
wrote:
> I report a weird behavior of linguist for a .ts file generated with 
> pylupdate4.
> 
> The python source code is
> 
> -------- begin code of test.py
> #!/usr/bin/python
> # -*- coding: utf8 -*-
> 
> import functools
> from PyQt4 import QtGui
> 
> tr = functools.partial( QtGui.QApplication.instance.translate, 'test.py')
> 
> YES = tr('Yes')
> NO = tr('No')
> 
> 
> ---------- end test.py
> 
> The .pro file is
> 
> ----------- begin test.pro
> SOURCES += ../test.py
> TRANSLATIONS += test_fr.ts
> ------------ end test.pro
> 
> I keep my translations in a subdirectory called translations. So you 
> need the ../ prefix to get to the source code. I run the following 
> commands in the translations subdirectory.
> 
> pylupdate4 test.pro
> linguist
> 
> Once in linguist I open the test_fr.ts file.
> 
> The weird behavior is twofold:
> 
> 1- When I go to the Source code window, linguist point to the line below 
> the one where the source text occurs. I.e when I translate the string 
> 'Yes' it points to the line NO = tr('NO').
> 
> 2- The contest string 'test.py' doesn't show up. Linguist reports 
> @default being the context.
> 
> 
> Could some of this have to do with the use of functools.partial with 
> translate? I thought this is a neat way to avoid repeating the same 
> string over and over when translating definitions made at module level. 
> It also let us alias the translation function to reduce typing and 
> increase readability.

Yes. pylupdate has no way of knowing what partial() does.

> I am using PyQt 4.3 on Ubuntu Hardy Heron. This is the most recent 
> version of PyQt that is packaged with Hardy.
> 
> 
> This is nothing more than a minor annoyance, but I think it is useful to 
> report anyway.

The line number problem should be fixed in tonight's snapshot.

Phil


More information about the PyQt mailing list