<div dir="ltr"><div><div>Hi all,<br>I'm testing a plugin I created with Plugin Builder on different platforms and encounter a problem I can't understand. The same piece of code works on Windows machines but not on MacOS ones where I get this error message. <br>

<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier New,courier""><br></span></p><p style="margin:0px;text-indent:0px"><span style="font-family:"Courier New,courier"">Traceback (most recent call last):<br>  File "/Users/harrissou/.qgis2/python/plugins/MapsPrinter/maps_printer.py", line 369, in saveFile<br>    progress.setLabelText(<a href="http://self.tr">self.tr</a>( u'Exporting maps from {}…'.format(title) ))<br>  File "/Users/harrissou/.qgis2/python/plugins/MapsPrinter/maps_printer.py", line 87, in tr<br>    return QCoreApplication.translate('MapsPrinter', message)<br>TypeError: function takes exactly 5 arguments (1 given)</span></p><br>QCoreApplication.translate is called in a tr function that is generated by Plugin Builder :<br><br>    def tr(self, message):<br>        """Get the translation for a string using Qt translation API.<br><br>        We implement this ourselves since we do not inherit QObject.<br><br>        :param message: String for translation.<br>        :type message: str, QString<br><br>        :returns: Translated version of message.<br>        :rtype: QString<br>        """<br>        # noinspection PyTypeChecker,PyArgumentList,PyCallByClass<br>        return QCoreApplication.translate('MapsPrinter', message)<br><br>Each time I run on MacOS, I get the previous error. But I remark that I don't get this error if in the saveFile function, instead of  <br><span style="font-family:"Courier New,courier"">progress.setLabelText(<a href="http://self.tr">self.tr</a>( u'Exporting maps from {}…'.format(title) ))<br></span>I put<br><span style="font-family:"Courier New,courier"">progress.setLabelText(<a href="http://self.tr">self.tr</a>( 'Exporting maps from {}…'.format(title) ))<br></span><br>All goes well except that I can't manage special characters and therefore can encounter an UnicodeEncodeError error (on both platforms). But it never complains about QCoreApplication.translate function.<br><br>

<p style="margin:0px;text-indent:0px"><span style="font-family:"Courier New,courier"">Traceback (most recent call last):<br>  File "/Users/harrissou/.qgis2/python/plugins/MapsPrinter/maps_printer.py", line 368, in saveFile<br>    progress.setLabelText(<a href="http://self.tr">self.tr</a>( 'Exporting maps from {}…'.format(title) ))<br>UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 11: ordinal not in range(128)</span></p><br></div>Any idea is welcome.<br></div>Thanks<br></div>