Skip to content
Snippets Groups Projects
Commit 6e4cea7b authored by Anton Stupak's avatar Anton Stupak
Browse files

Merge pull request #3590 from edx/anton/i18n-string-response

StringResponse i18n.
parents 799c3611 d9aa28b8
No related merge requests found
...@@ -1375,6 +1375,7 @@ class StringResponse(LoncapaResponse): ...@@ -1375,6 +1375,7 @@ class StringResponse(LoncapaResponse):
Note: for old code, which supports _or_ separator, we add some backward compatibility handling. Note: for old code, which supports _or_ separator, we add some backward compatibility handling.
Should be removed soon. When to remove it, is up to Lyla Fisher. Should be removed soon. When to remove it, is up to Lyla Fisher.
""" """
_ = self.capa_system.i18n.ugettext
# backward compatibility, should be removed in future. # backward compatibility, should be removed in future.
if self.backward: if self.backward:
return self.check_string_backward(expected, given) return self.check_string_backward(expected, given)
...@@ -1386,7 +1387,10 @@ class StringResponse(LoncapaResponse): ...@@ -1386,7 +1387,10 @@ class StringResponse(LoncapaResponse):
regexp = re.compile('^' + '|'.join(expected) + '$', flags=flags | re.UNICODE) regexp = re.compile('^' + '|'.join(expected) + '$', flags=flags | re.UNICODE)
result = re.search(regexp, given) result = re.search(regexp, given)
except Exception as err: except Exception as err:
msg = '[courseware.capa.responsetypes.stringresponse] error: {}'.format(err.message) msg = u'[courseware.capa.responsetypes.stringresponse] {error}: {message}'.format(
error=_(u'error'),
message=err.message
)
log.error(msg, exc_info=True) log.error(msg, exc_info=True)
raise ResponseError(msg) raise ResponseError(msg)
return bool(result) return bool(result)
...@@ -1410,7 +1414,9 @@ class StringResponse(LoncapaResponse): ...@@ -1410,7 +1414,9 @@ class StringResponse(LoncapaResponse):
return hints_to_show return hints_to_show
def get_answers(self): def get_answers(self):
return {self.answer_id: ' <b>or</b> '.join(self.correct_answer)} _ = self.capa_system.i18n.ugettext
separator = u' <b>{}</b> '.format(_(u'or'))
return {self.answer_id: separator.join(self.correct_answer)}
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment