Skip to content
Permalink
Browse files

make python error handling translatable

  • Loading branch information
jef-n committed Oct 23, 2015
1 parent e5ad57b commit b65b59596aab975bc49e830fab4175a4cd199f99
Showing with 5 additions and 6 deletions.
  1. +5 −6 python/utils.py
@@ -91,16 +91,15 @@ def showException(type, value, tb, msg, messagebar=False):
# Grab the first message bar for now
bar = widgets[0]


item = bar.currentItem()
if item and item.property("Error") == msg:
# Return of we already have a message with the same error message
return

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

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

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

0 comments on commit b65b595

Please sign in to comment.
You can’t perform that action at this time.