[Qgis-developer] Translation files - creating a .pro file

Larry Shaffer larrys at dakotacarto.com
Tue Mar 20 14:12:35 EDT 2012


Hi Bert,

On Tue, Mar 20, 2012 at 10:35 AM, bertGIS <bidou_smithers at hotmail.com> wrote:
> Hello.
> How can we do to create a .pro file in order to generate .ts files, taking
> in account a python plugins UI files ?
> Can we have a correct .pro using QTCreator ?
> How to import ui files correctly in the .pro file?

I'm not sure I understand your question, but here are some resources
for translating a PyQGIS plugin:

http://qt-project.org/doc/qt-4.8/linguist-manual.html

http://qt-project.org/doc/qt-4.8/qobject.html#tr

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html

Basically, you need to wrap all visible, translatable strings with a
given QObject's tr() or trUtf8() method, or
QtGui.QApplication.translate(). Then, pylupdate4 can be used to
generate the .ts files for use in Qt Linguist.

When working in Qt Creator or Designer, make sure any gui item's text
you want translated has 'translatable' checked (default). Then, it's
pyuic4-generated .py will have wrapped strings.

Most PyQGIS deployed plugins have their .pro file removed, but the
'Shift Points' and 'EasyPrint' plugins have a .pro, MAKEFILE and i18n
directory setup in their source you can examine. Both also show how to
instantiate the QTranslator() object in their base classes, for
effecting the plugin's on-the-fly translation.

Regards,

Larry Shaffer
Dakota Cartography
Black Hills, South Dakota


More information about the Qgis-developer mailing list