Skip to content

Commit b65b595

Browse files
committedOct 23, 2015
make python error handling translatable
1 parent e5ad57b commit b65b595

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed
 

‎python/utils.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,15 @@ def showException(type, value, tb, msg, messagebar=False):
9191
# Grab the first message bar for now
9292
bar = widgets[0]
9393

94-
9594
item = bar.currentItem()
9695
if item and item.property("Error") == msg:
9796
# Return of we already have a message with the same error message
9897
return
9998

100-
widget = bar.createMessage(title, msg + " See message log (Python Error) for more details.")
99+
widget = bar.createMessage(title, msg + " " + QCoreApplication.translate("Python", "See message log (Python Error) for more details."))
101100
widget.setProperty("Error", msg)
102-
stackbutton = QPushButton("Stack trace", pressed=functools.partial(open_stack_dialog, type, value, tb, msg))
103-
button = QPushButton("View message log", pressed=show_message_log)
101+
stackbutton = QPushButton(QCoreApplication.translate("Python", "Stack trace"), pressed=functools.partial(open_stack_dialog, type, value, tb, msg))
102+
button = QPushButton(QCoreApplication.translate("Python", "View message log"), pressed=show_message_log)
104103
widget.layout().addWidget(stackbutton)
105104
widget.layout().addWidget(button)
106105
bar.pushWidget(widget, QgsMessageBar.WARNING)
@@ -121,7 +120,7 @@ def open_stack_dialog(type, value, tb, msg, pop_error=True):
121120
msg = QCoreApplication.translate('Python', 'An error has occured while executing Python code:')
122121

123122
# TODO Move this to a template HTML file
124-
txt = '''<font color="red"><b>{msg}</b></font>
123+
txt = u'''<font color="red"><b>{msg}</b></font>
125124
<br>
126125
<h3>{main_error}</h3>
127126
<pre>
@@ -158,7 +157,7 @@ def open_stack_dialog(type, value, tb, msg, pop_error=True):
158157
qgisrelease=QGis.QGIS_RELEASE_NAME,
159158
devversion=QGis.QGIS_DEV_VERSION,
160159
pypath_label=pypath_label,
161-
pypath="".join("<li>{}</li>".format(path) for path in sys.path))
160+
pypath=u"".join(u"<li>{}</li>".format(path) for path in sys.path))
162161

163162
txt = txt.replace(' ', '&nbsp; ') # preserve whitespaces for nicer output
164163

0 commit comments

Comments
 (0)
Please sign in to comment.