[PyQt] Docs on how pylupdate4 finds strings?
Dave Peterson
dpeterson at enthought.com
Fri Aug 21 00:28:26 BST 2009
I'm having trouble getting pylupdate4 (version 4.5.1) to detect strings
that need translation in my python files. And after numerous searches,
I can't seem to find any docs explaining how the tool goes about finding
strings that need translation, so I'm not even sure how to go about
debugging things.
Ideally, I'd like my project to have a util.py module containing a tr()
function that I can then use throughout the rest of my code. This
module might look something like:
from PyQt4 import QtGui
def tr(context, text):
return QtGui.QApplication.translate(context, text, None,
QtGui.QApplication.UnicodeUTF8)
And then in any other project module I could simply do:
from util import tr
CONTEXT='MainMenu'
menu1 = Menu(name=tr(CONTEXT, u'File'), ....)
menu2 = Menu(name=tr(CONTEXT, u'View'), ....)
etc.
However, for the life of me, I can't get pylupdate4 to detect the
strings 'File' and 'View'. I've even tried "inlining" by doing
something like:
menu1 = Menu(name=QtGui.QApplication.translate('MainMenu', u'File'),
...)
but that doesn't work either.
Can anyone offer advice or point me at some docs for how pylupdate4 does
it's scanning?
-- Dave
More information about the PyQt
mailing list