[QGIS-Developer] Plugins translation

Jorge Almerio jorgealmerio at yahoo.com.br
Tue Aug 7 09:25:47 PDT 2018

Hi devs,


For do the plugin translations I use


1) Linguist from QT5

2) The command line: 

    Pylupdate4 -noobsolete PluginName.pro (Is there a new version 5??)

3) and the classical code:


        # initialize locale
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(

        if os.path.exists(locale_path):
            self.translator = QTranslator()

            if qVersion() > '4.3.3':



        def tr(self, message):

            return QCoreApplication.translate(QWaterPlugin.SETTINGS, message)



The problem is that the option to use self.tr('message string') is not working. It only works when I use QCoreApplication.translate('Escope', 'message string') even if a tr function defined.


It used to work with linguist from QT4.


What  Am I doing wrong? BTW Is there a new better way to translate plugins?


Another thing, every time I update the translations strings with Pylupdate4, I have to translate all my plugin forms again even without any changes, any help???




Jorge Almerio


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180807/411d94bd/attachment.html>

More information about the QGIS-Developer mailing list