Skip to content

Commit

Permalink
py3: code from python3-branch broke the translation in Start-wb. This…
Browse files Browse the repository at this point in the history
… commit should fix this
  • Loading branch information
looooo committed Jan 21, 2017
1 parent f3f7b01 commit 4915a09
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/Mod/Start/StartPage/StartPage.py
Expand Up @@ -40,25 +40,30 @@ def translate(context,text):
# return str(QtGui.QApplication.translate(context, text, None, QtGui.QApplication.UnicodeUTF8).toUtf8())
try:
_encoding = QtGui.QApplication.UnicodeUTF8
u = QtGui.QApplication.translate(context, text, None, _encoding).encode("utf8")
u = QtGui.QApplication.translate(context, text, None, _encoding)
except AttributeError:
u = QtGui.QApplication.translate(context, text, None).encode("utf8")

s = cStringIO.StringIO()
for i in u:
if sys.version_info.major > 2: #below only works correctly in python3
if i == 39:
s.write("\\'")
else:
s.write(chr(i))
else:
if ord(i) == 39:
s.write(unicode("\\'"))
else:
s.write(unicode(i))
t = s.getvalue()
s.close()
return t
u = QtGui.QApplication.translate(context, text, None)

if sys.version_info.major < 3:
u = u.encode("utf8")

# s = cStringIO.StringIO()
# for i in u:
# if sys.version_info.major > 2: #below only works correctly in python3
# if i == 39:
# s.write("\\'")
# else:
# s.write(chr(i))
# else:
# if ord(i) == 39:
# s.write(unicode("\\'"))
# else:
# s.write(unicode(i))
# t = s.getvalue()
# s.close()
# return t

return u.replace(chr(39), "\\'")

# texts to be translated

Expand Down

0 comments on commit 4915a09

Please sign in to comment.