From fec487dc7fb03a633753e2c18df3b18fd9e4601c Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 16 Dec 2018 16:25:25 +0100 Subject: [PATCH] fix translate() function for Py2 & Qt5 --- src/Mod/Draft/DraftGui.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py index 6728a859d7..042d308e11 100644 --- a/src/Mod/Draft/DraftGui.py +++ b/src/Mod/Draft/DraftGui.py @@ -81,10 +81,16 @@ except AttributeError: """ if sys.version_info.major >= 3: return QtGui.QApplication.translate(context, text, None) - elif utf8_decode: - return QtGui.QApplication.translate(context, text, None, _encoding) + elif QtCore.qVersion() > "4": + if utf8_decode: + return QtGui.QApplication.translate(context, text, None) + else: + return QtGui.QApplication.translate(context, text, None).encode("utf8") else: - return QtGui.QApplication.translate(context, text, None, _encoding).encode("utf8") + if utf8_decode: + return QtGui.QApplication.translate(context, text, None, _encoding) + else: + return QtGui.QApplication.translate(context, text, None, _encoding).encode("utf8") def utf8_decode(text): """py2: str -> unicode