[QGIS-Developer] translate plugin gui and log messages

Roberta Fagandini robifagandini at gmail.com
Tue Jun 18 09:47:15 PDT 2019


Hi all,
I want to translate both the gui and all the log messages of my plugin in a
certain language (e.g. Italian). I'm using Qt Creator and Qt Linguist.
I created a plugin.pro file which contains all the file with text strings
that have to be translated (i.e. my .ui and .py files). Then I used Qt
Creator to generate the plugin_it.ts file and I modified this file with Qt
Linguist generating at the end a .qm file.
The translation of the gui (file .ui) works fine but I have problems with
the translation of the log messages in the .py file.
I marked all the strings that I want to translate putting them inside the
tr() function but Qt Linguist does not seem to recognize them as strings to
be translated.
Messages are simple text string appended to a QTextBrowser widget.

The plugin was initially created with the Plugin Builder, therefore I have
a tr() function, I have imported QTranslator and all the rows created by
Plugin Builder regarding translation have not been modified.

Any suggestion?

Thanks in advance,
Roberta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190618/c1911ea4/attachment.html>


More information about the QGIS-Developer mailing list