[QGIS-Developer] translate plugin gui and log messages

Jonas qgis at ag99.de
Tue Jun 18 14:50:36 PDT 2019


Hi Roberta,

You do not mention using the pylupdate program, you should use that to 
create the ts files, because only this way you extract the text strings 
from the python files. Qt Creator does not care about the python scripts 
at all.

see
https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/plugins.html?highlight=plugin#ts-file
https://www.riverbankcomputing.com/static/Docs/PyQt5/i18n.html


Cheers

Jonas


On 18.06.2019 18:47, Roberta Fagandini wrote:
> 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 <http://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/b76e0e3d/attachment.html>


More information about the QGIS-Developer mailing list