Changeset 2463


Ignore:
Timestamp:
07/03/08 16:40:20 (11 years ago)
Author:
anonymous
Message:

Fixes ##1763. _() syntax does not work, need to use self.translate.
However, no strings should be in python code, only in python scripts
and templates. Also note: next time vocabulary update is run, these
strings won't be found. So either they need to be moved to templates,
or the i18n extractor needs an update.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ExerciseMaterial.py

    r2449 r2463  
    213213        # If the form has not been submitted -> only this mesage will be shown 
    214214        if not REQUEST.get('submit_web_feedback',''): 
    215             msg = _(u"text_web_feedback_message_not_generated", u"Unable to generate the feedback. You have not submitted the form.") 
     215            msg = self.translate(u"text_web_feedback_message_not_generated", u"Unable to generate the feedback. You have not submitted the form.",domain='lemill') 
    216216            return (feedbody, (msg, 'warn')) 
    217217 
     
    253253                # Add the html result to the general holder 
    254254                percentage = int((float(answered_right)/(answered_wrong+answered_right))*100) 
    255                 result_text = _(u"text_web_feedback_mc_result", u"""You got %(percentage)s%% correct!""") % {'percentage':percentage} 
     255                result_text = self.translate(u"text_web_feedback_mc_result", u"""You got %(percentage)s%% correct!""",domain='lemill') % {'percentage':percentage} 
    256256                feedbody += u"""<p>%s</p> <p>%s</p>""" % (to_unicode(chapter_text[0]), mchoice_body) 
    257257                feedbody += u"""<p><strong>%s</strong></p>""" % (result_text) 
     
    271271                # Using external helper method to replace the blanks and construct the html 
    272272                exercise_text = self.replace_blanks_with_feedback(chapter_text, my_answer_dict, i) 
    273                 result_text = _(u"text_web_feedback_fitb_result", u"""You got %(right_n)s/%(all_n)s correct!""") % {'right_n':correct_answers_n, 'all_n':all_answers_n} 
     273                result_text = self.translate(u"text_web_feedback_fitb_result", u"""You got %(right_n)s/%(all_n)s correct!""",domain='lemill') % {'right_n':correct_answers_n, 'all_n':all_answers_n} 
    274274                # Add the html result to the general holder 
    275275                feedbody += u"""%s""" % (exercise_text) 
     
    294294 
    295295        if not students_email or (teachers_email and not students_name): 
    296             msg = _(u"text_mail_feedback_no_information", u"You have not provided enough information to send an e-mail.") 
     296            msg = self.translate(u"text_mail_feedback_no_information", u"You have not provided enough information to send an e-mail.",domain='lemill') 
    297297            # Messages are translated here, every message should also have a type along with it 
    298298            return (msg, 'warn') 
    299299 
    300300        if not self.lemill_tool.validateCaptcha(REQUEST.get('captcha')): 
    301             msg = _(u"Invalid answer for humanity test.") 
     301            msg = self.translate(u"Invalid answer for humanity test.",domain='lemill') 
    302302            return (msg, 'warn') 
    303303         
     
    307307        # Now we should compose the message body         
    308308        if teachers_email: 
    309             mbody += _(u"""Hello, 
     309            mbody += self.translate(u"""Hello, 
    310310 
    311311%(name)s has completed the LeMill exercise '%(exercise_title)s' at %(exercise_url)s. 
    312 """) % {'name':to_unicode(students_name), 'exercise_title':to_unicode(self.Title()), 'exercise_url':to_unicode(self.absolute_url())}  
     312""",domain='lemill') % {'name':to_unicode(students_name), 'exercise_title':to_unicode(self.Title()), 'exercise_url':to_unicode(self.absolute_url())}  
    313313        else: 
    314             mbody += _(u"""Hello %(name)s, 
     314            mbody += self.translate(u"""Hello %(name)s, 
    315315 
    316316You have completed the LeMill exercise '%(exercise_title)s' at %(exercise_url)s. 
    317 """) % {'name':to_unicode(students_name), 'exercise_title':to_unicode(self.Title()), 'exercise_url':to_unicode(self.absolute_url())} 
    318  
    319         mbody += _(u"text_mail_feedback_message_body_explanation", u"If you are surprised by getting this e-mail, you can simply ignore and delete it as someone may have accidentally inserted your address as a recipient.") 
     317""",domain='lemill') % {'name':to_unicode(students_name), 'exercise_title':to_unicode(self.Title()), 'exercise_url':to_unicode(self.absolute_url())} 
     318 
     319        mbody += self.translate(u"text_mail_feedback_message_body_explanation", u"If you are surprised by getting this e-mail, you can simply ignore and delete it as someone may have accidentally inserted your address as a recipient.",domain='lemill') 
    320320        # Message body is composed chapter by chapter 
    321321        i=0 
     
    345345                        answered_right+=1 
    346346                percentage=int((float(answered_right)/(answered_wrong+answered_right))*100) 
    347                 mbody += _(u"""Your answer to question '%(question)s' was: 
     347                mbody += self.translate(u"""Your answer to question '%(question)s' was: 
    348348%(my_answers)s 
    349349The correct answer is: 
    350350%(correct_answers)s 
    351351You got %(percentage)s%% correct! 
    352 """) % {'question':to_unicode(question), 'my_answers':to_unicode(', '.join(my_answers)), 'correct_answers':to_unicode(', '.join(correct_answers)), 'percentage':percentage} 
     352""",domain='lemill') % {'question':to_unicode(question), 'my_answers':to_unicode(', '.join(my_answers)), 'correct_answers':to_unicode(', '.join(correct_answers)), 'percentage':percentage} 
    353353 
    354354            elif chapter_type == 'fill_in_the_blanks': 
     
    365365                exercise_text=self.replace_blanks_with_your_answers(chapter_text, my_answer_dict, i) 
    366366                exercise_text=letool.html_to_text(exercise_text) 
    367                 mbody += _(u"""Answer entered by student is in the square brackets. The correct answer is in the logical brackets. 
     367                mbody += self.translate(u"""Answer entered by student is in the square brackets. The correct answer is in the logical brackets. 
    368368In the following fill-in-the-blanks exercise your answers and correct answers were: 
    369369%(exercise_text)s 
    370370 
    371371You got %(correct_answers_n)s/%(all_answers_n)s correct! 
    372 """) % {'exercise_text':to_unicode(exercise_text), 'correct_answers_n':correct_answers_n, 'all_answers_n':all_answers_n}             
     372""",domain='lemill') % {'exercise_text':to_unicode(exercise_text), 'correct_answers_n':correct_answers_n, 'all_answers_n':all_answers_n}             
    373373 
    374374            elif chapter_type == 'open_ended': 
    375375                students_answer = REQUEST.get('exercise_%s_answer' % i, '') 
    376                 mbody += _(u"""Your answer to question '%(question)s' was: 
     376                mbody += self.translate(u"""Your answer to question '%(question)s' was: 
    377377%(answer)s 
    378378 
    379379Your teacher will give you feedback on your answer. 
    380 """) % {'question':to_unicode(chapter_text), 'answer':to_unicode(students_answer)} 
     380""",domain='lemill') % {'question':to_unicode(chapter_text), 'answer':to_unicode(students_answer)} 
    381381            i+=1 # <--- remember to increase index 
    382382             
    383         mbody += '\n\n'+ _(u"text_mail_feedback_message_body_regards", u"Best regards, LeMill") 
     383        mbody += '\n\n'+ self.translate(u"text_mail_feedback_message_body_regards", u"Best regards, LeMill",domain='lemill') 
    384384        mbody = mbody.encode('utf-8') 
    385385 
     
    389389            try: 
    390390                mhost.secureSend(mbody, mto=teachers_email, mfrom=message_from, subject=message_subject, mcc=students_email, charset='utf-8') 
    391                 msg = _(u"text_mail_feedback_message_sent_both", u"The e-mail has been sent to you and a teacher.") 
     391                msg = self.translate(u"text_mail_feedback_message_sent_both", u"The e-mail has been sent to you and a teacher.",domain='lemill') 
    392392                return (msg, 'mess') 
    393393            except: 
    394                 msg = _(u"The e-mail could not be sent.") 
     394                msg = self.translate(u"The e-mail could not be sent.",domain='lemill') 
    395395                return (msg, 'warn') 
    396396        else: 
     
    399399            try: 
    400400                mhost.secureSend(mbody, mto=students_email, mfrom=message_from, subject=message_subject, charset='utf-8') 
    401                 msg = _(u"text_mail_feedback_message_sent_one", u"The e-mail has been sent to you.") 
     401                msg = self.translate(u"text_mail_feedback_message_sent_one", u"The e-mail has been sent to you.",domain='lemill') 
    402402                return (msg, 'mess') 
    403403            except: 
    404                 msg = _(u"The e-mail could not be sent.") 
     404                msg = self.translate(u"The e-mail could not be sent.",domain='lemill') 
    405405                return (msg, 'warn') 
    406406 
Note: See TracChangeset for help on using the changeset viewer.