From ca93855fcf6c33986eca1efc539436e7f1423789 Mon Sep 17 00:00:00 2001 From: polesye Date: Tue, 22 Apr 2014 12:13:13 +0300 Subject: [PATCH] BLD-717: MultipleChoiceResponse i18n. --- common/lib/capa/capa/responsetypes.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index eacde78f60..2c2868a1a2 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -843,7 +843,10 @@ class MultipleChoiceResponse(LoncapaResponse): Fails with LoncapaProblemError if called on a response that is not masking. """ if not self.has_mask(): - raise LoncapaProblemError("unmask_name called on response that is not masked") + _ = self.capa_system.i18n.ugettext + # Translators: 'unmask_name' is a method name and should not be translated. + msg = _("unmask_name called on response that is not masked") + raise LoncapaProblemError(msg) return self._mask_dict[name] def unmask_order(self): @@ -870,7 +873,10 @@ class MultipleChoiceResponse(LoncapaResponse): if choicegroups: choicegroup = choicegroups[0] if choicegroup.get('answer-pool') is not None: - raise LoncapaProblemError("Do not use shuffle and answer-pool at the same time") + _ = self.capa_system.i18n.ugettext + # Translators: 'shuffle' and 'answer-pool' are attribute names and should not be translated. + msg = _("Do not use shuffle and answer-pool at the same time") + raise LoncapaProblemError(msg) # Note in the response that shuffling is done. # Both to avoid double-processing, and to feed the logs. if self.has_shuffle(): @@ -950,7 +956,10 @@ class MultipleChoiceResponse(LoncapaResponse): try: num_choices = int(num_str) except ValueError: - raise LoncapaProblemError("answer-pool value should be an integer") + _ = self.capa_system.i18n.ugettext + # Translators: 'answer-pool' is an attribute name and should not be translated. + msg = _("answer-pool value should be an integer") + raise LoncapaProblemError(msg) # Note in the response that answerpool is done. # Both to avoid double-processing, and to feed the logs. @@ -1014,7 +1023,10 @@ class MultipleChoiceResponse(LoncapaResponse): # Or perhaps in the overall author workflow, these errors are unhelpful and # should all be removed. if len(correct_choices) < 1 or len(incorrect_choices) < 1: - raise LoncapaProblemError("Choicegroup must include at least 1 correct and 1 incorrect choice") + _ = self.capa_system.i18n.ugettext + # Translators: 'Choicegroup' is an input type and should not be translated. + msg = _("Choicegroup must include at least 1 correct and 1 incorrect choice") + raise LoncapaProblemError(msg) # Limit the number of incorrect choices to what we actually have num_incorrect = num_pool - 1