Merge pull request #4085 from edx/jmclaus/i18n-chemical-equation-input
ChemicalEquationInput: i18n
This commit is contained in:
@@ -1156,23 +1156,24 @@ class ChemicalEquationInput(InputTypeBase):
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_ = self.capa_system.i18n.ugettext
|
||||||
result = {'preview': '',
|
result = {'preview': '',
|
||||||
'error': ''}
|
'error': ''}
|
||||||
try:
|
try:
|
||||||
formula = data['formula']
|
formula = data['formula']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
result['error'] = "No formula specified."
|
result['error'] = _("No formula specified.")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result['preview'] = chemcalc.render_to_html(formula)
|
result['preview'] = chemcalc.render_to_html(formula)
|
||||||
except pyparsing.ParseException as err:
|
except pyparsing.ParseException as err:
|
||||||
result['error'] = u"Couldn't parse formula: {0}".format(err.msg)
|
result['error'] = _("Couldn't parse formula: {error_msg}").format(error_msg=err.msg)
|
||||||
except Exception:
|
except Exception:
|
||||||
# this is unexpected, so log
|
# this is unexpected, so log
|
||||||
log.warning(
|
log.warning(
|
||||||
"Error while previewing chemical formula", exc_info=True)
|
"Error while previewing chemical formula", exc_info=True)
|
||||||
result['error'] = "Error while rendering preview"
|
result['error'] = _("Error while rendering preview")
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user