-

${_("Welcome, {0}!".format(user.username))}

+

${_("Welcome, {0}!").format(user.username)}

%if len(courses) > 0:
diff --git a/common/djangoapps/django_comment_common/models.py b/common/djangoapps/django_comment_common/models.py index 7878f1b453cf..6e088e5e5842 100644 --- a/common/djangoapps/django_comment_common/models.py +++ b/common/djangoapps/django_comment_common/models.py @@ -11,10 +11,12 @@ from xmodule.modulestore.django import modulestore from xmodule.course_module import CourseDescriptor -FORUM_ROLE_ADMINISTRATOR = 'Administrator' -FORUM_ROLE_MODERATOR = 'Moderator' -FORUM_ROLE_COMMUNITY_TA = 'Community TA' -FORUM_ROLE_STUDENT = 'Student' +from django.utils.translation import ugettext_noop + +FORUM_ROLE_ADMINISTRATOR = ugettext_noop('Administrator') +FORUM_ROLE_MODERATOR = ugettext_noop('Moderator') +FORUM_ROLE_COMMUNITY_TA = ugettext_noop('Community TA') +FORUM_ROLE_STUDENT = ugettext_noop('Student') @receiver(post_save, sender=CourseEnrollment) diff --git a/common/static/coffee/src/discussion/discussion_module_view.coffee b/common/static/coffee/src/discussion/discussion_module_view.coffee index f99eba3872e7..8b74b7d49854 100644 --- a/common/static/coffee/src/discussion/discussion_module_view.coffee +++ b/common/static/coffee/src/discussion/discussion_module_view.coffee @@ -28,7 +28,7 @@ if Backbone? else @newPostForm.show() @toggleDiscussionBtn.addClass('shown') - @toggleDiscussionBtn.find('.button-text').html("Hide Discussion") + @toggleDiscussionBtn.find('.button-text').html(gettext("Hide Discussion")) @$("section.discussion").slideDown() @showed = true @@ -39,7 +39,7 @@ if Backbone? hideDiscussion: -> @$("section.discussion").slideUp() @toggleDiscussionBtn.removeClass('shown') - @toggleDiscussionBtn.find('.button-text').html("Show Discussion") + @toggleDiscussionBtn.find('.button-text').html(gettext("Show Discussion")) @showed = false toggleDiscussion: (event) -> @@ -47,7 +47,7 @@ if Backbone? @hideDiscussion() else @toggleDiscussionBtn.addClass('shown') - @toggleDiscussionBtn.find('.button-text').html("Hide Discussion") + @toggleDiscussionBtn.find('.button-text').html(gettext("Hide Discussion")) if @retrieved @$("section.discussion").slideDown() diff --git a/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee b/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee index 57385c15bd7e..3637e7fefa6e 100644 --- a/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee +++ b/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee @@ -119,12 +119,12 @@ if Backbone? renderMorePages: -> if @displayedCollection.hasMorePages() - @$(".post-list").append("
  • Load more
  • ") + @$(".post-list").append("
  • " + gettext('Load more')+ "
  • ") loadMorePages: (event) -> if event event.preventDefault() - @$(".more-pages").html('
    Loading more threads
    ') + @$(".more-pages").html('
    ' + gettext("Loading more threads") + '
    ') @$(".more-pages").addClass("loading") loadingDiv = @$(".more-pages .loading-animation") DiscussionUtil.makeFocusTrap(loadingDiv) diff --git a/common/static/coffee/src/discussion/views/discussion_thread_show_view.coffee b/common/static/coffee/src/discussion/views/discussion_thread_show_view.coffee index b5f478a8afb9..494b3b65caaf 100644 --- a/common/static/coffee/src/discussion/views/discussion_thread_show_view.coffee +++ b/common/static/coffee/src/discussion/views/discussion_thread_show_view.coffee @@ -49,22 +49,22 @@ if Backbone? @$("[data-role=thread-flag]").addClass("flagged") @$("[data-role=thread-flag]").removeClass("notflagged") @$(".discussion-flag-abuse").attr("aria-pressed", "true") - @$(".discussion-flag-abuse .flag-label").html("Misuse Reported") + @$(".discussion-flag-abuse .flag-label").html(gettext("Misuse Reported")) else @$("[data-role=thread-flag]").removeClass("flagged") @$("[data-role=thread-flag]").addClass("notflagged") @$(".discussion-flag-abuse").attr("aria-pressed", "false") - @$(".discussion-flag-abuse .flag-label").html("Report Misuse") + @$(".discussion-flag-abuse .flag-label").html(gettext("Report Misuse")) renderPinned: => if @model.get("pinned") @$("[data-role=thread-pin]").addClass("pinned") @$("[data-role=thread-pin]").removeClass("notpinned") - @$(".discussion-pin .pin-label").html("Pinned") + @$(".discussion-pin .pin-label").html(gettext("Pinned")) else @$("[data-role=thread-pin]").removeClass("pinned") @$("[data-role=thread-pin]").addClass("notpinned") - @$(".discussion-pin .pin-label").html("Pin Thread") + @$(".discussion-pin .pin-label").html(gettext("Pin Thread")) updateModelDetails: => @@ -137,7 +137,7 @@ if Backbone? if textStatus == 'success' @model.set('pinned', true) error: => - $('.admin-pin').text("Pinning not currently available") + $('.admin-pin').text(gettext("Pinning not currently available")) unPin: -> url = @model.urlFor("unPinThread") diff --git a/common/static/coffee/src/discussion/views/response_comment_show_view.coffee b/common/static/coffee/src/discussion/views/response_comment_show_view.coffee index 0e51d6a11a5c..6ea324a52ec9 100644 --- a/common/static/coffee/src/discussion/views/response_comment_show_view.coffee +++ b/common/static/coffee/src/discussion/views/response_comment_show_view.coffee @@ -24,7 +24,7 @@ if Backbone? addReplyLink: () -> if @model.hasOwnProperty('parent') - name = @model.parent.get('username') ? "anonymous" + name = @model.parent.get('username') ? gettext("anonymous") html = "@#{name}: " p = @$('.response-body p:first') p.prepend(html) @@ -36,7 +36,7 @@ if Backbone? markAsStaff: -> if DiscussionUtil.isStaff(@model.get("user_id")) - @$el.find("a.profile-link").after('staff') + @$el.find("a.profile-link").after('' + gettext('staff') + '') else if DiscussionUtil.isTA(@model.get("user_id")) @$el.find("a.profile-link").after('Community  TA') diff --git a/common/static/coffee/src/discussion/views/thread_response_show_view.coffee b/common/static/coffee/src/discussion/views/thread_response_show_view.coffee index aaff4a4a3911..5b5e5487d7f5 100644 --- a/common/static/coffee/src/discussion/views/thread_response_show_view.coffee +++ b/common/static/coffee/src/discussion/views/thread_response_show_view.coffee @@ -24,7 +24,7 @@ if Backbone? @delegateEvents() if window.user.voted(@model) @$(".vote-btn").addClass("is-cast") - @$(".vote-btn span.sr").html("votes (click to remove your vote)") + @$(".vote-btn span.sr").html(gettext("votes (click to remove your vote)")) @renderAttrs() @renderFlagged() @$el.find(".posted-details").timeago() @@ -40,7 +40,7 @@ if Backbone? markAsStaff: -> if DiscussionUtil.isStaff(@model.get("user_id")) @$el.addClass("staff") - @$el.prepend('
    staff
    ') + @$el.prepend('
    ' + gettext('staff') + '
    ') else if DiscussionUtil.isTA(@model.get("user_id")) @$el.addClass("community-ta") @$el.prepend('
    Community TA
    ') @@ -50,10 +50,10 @@ if Backbone? @$(".vote-btn").toggleClass("is-cast") if @$(".vote-btn").hasClass("is-cast") @vote() - @$(".vote-btn span.sr").html("votes (click to remove your vote)") + @$(".vote-btn span.sr").html(gettext("votes (click to remove your vote)")) else @unvote() - @$(".vote-btn span.sr").html("votes (click to vote)") + @$(".vote-btn span.sr").html(gettext("votes (click to vote)")) vote: -> url = @model.urlFor("upvote") @@ -106,12 +106,12 @@ if Backbone? @$("[data-role=thread-flag]").addClass("flagged") @$("[data-role=thread-flag]").removeClass("notflagged") @$(".discussion-flag-abuse").attr("aria-pressed", "true") - @$(".discussion-flag-abuse .flag-label").html("Misuse Reported") + @$(".discussion-flag-abuse .flag-label").html(gettext("Misuse Reported")) else @$("[data-role=thread-flag]").removeClass("flagged") @$("[data-role=thread-flag]").addClass("notflagged") @$(".discussion-flag-abuse").attr("aria-pressed", "false") - @$(".discussion-flag-abuse .flag-label").html("Report Misuse") + @$(".discussion-flag-abuse .flag-label").html(gettext("Report Misuse")) updateModelDetails: => @renderFlagged() diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py index 98c18dc68bea..4354bdc71723 100644 --- a/lms/djangoapps/instructor/views/legacy.py +++ b/lms/djangoapps/instructor/views/legacy.py @@ -173,7 +173,7 @@ def get_student_from_identifier(unique_student_identifier): msg += "Found a single student. " except User.DoesNotExist: student = None - msg += "Couldn't find student with that email or username. " + msg += "" + _u("Couldn't find student with that email or username.") + " " return msg, student # process actions from form POST @@ -211,20 +211,20 @@ def get_student_from_identifier(unique_student_identifier): if action == 'Dump list of enrolled students' or action == 'List enrolled students': log.debug(action) datatable = get_student_grade_summary_data(request, course, course_id, get_grades=False, use_offline=use_offline) - datatable['title'] = 'List of students enrolled in {0}'.format(course_id) + datatable['title'] = _u('List of students enrolled in {0}').format(course_id) track.views.server_track(request, "list-students", {}, page="idashboard") elif 'Dump Grades' in action: log.debug(action) datatable = get_student_grade_summary_data(request, course, course_id, get_grades=True, use_offline=use_offline) - datatable['title'] = 'Summary Grades of students enrolled in {0}'.format(course_id) + datatable['title'] = _u('Summary Grades of students enrolled in {0}').format(course_id) track.views.server_track(request, "dump-grades", {}, page="idashboard") elif 'Dump all RAW grades' in action: log.debug(action) datatable = get_student_grade_summary_data(request, course, course_id, get_grades=True, get_raw_scores=True, use_offline=use_offline) - datatable['title'] = 'Raw Grades of students enrolled in {0}'.format(course_id) + datatable['title'] = _u('Raw Grades of students enrolled in {0}').format(course_id) track.views.server_track(request, "dump-grades-raw", {}, page="idashboard") elif 'Download CSV of all student grades' in action: @@ -252,14 +252,14 @@ def get_student_from_identifier(unique_student_identifier): try: instructor_task = submit_rescore_problem_for_all_students(request, course_id, problem_url) if instructor_task is None: - msg += 'Failed to create a background task for rescoring "{0}".'.format(problem_url) + msg += '' + _u('Failed to create a background task for rescoring "{0}".').format(problem_url) + '' else: track.views.server_track(request, "rescore-all-submissions", {"problem": problem_url, "course": course_id}, page="idashboard") except ItemNotFoundError as err: - msg += 'Failed to create a background task for rescoring "{0}": problem not found.'.format(problem_url) + msg += '' + _u('Failed to create a background task for rescoring "{0}": problem not found.').format(problem_url) + '' except Exception as err: log.error("Encountered exception from rescore: {0}".format(err)) - msg += 'Failed to create a background task for rescoring "{0}": {1}.'.format(problem_url, err.message) + msg += '' + _u('Failed to create a background task for rescoring "{url}": {message}.').format(url = problem_url, message = err.message) + '' elif "Reset ALL students' attempts" in action: problem_urlname = request.POST.get('problem_for_all_students', '') @@ -267,15 +267,15 @@ def get_student_from_identifier(unique_student_identifier): try: instructor_task = submit_reset_problem_attempts_for_all_students(request, course_id, problem_url) if instructor_task is None: - msg += 'Failed to create a background task for resetting "{0}".'.format(problem_url) + msg += '' + _u('Failed to create a background task for resetting "{0}".').format(problem_url) + '' else: track.views.server_track(request, "reset-all-attempts", {"problem": problem_url, "course": course_id}, page="idashboard") except ItemNotFoundError as err: log.error('Failure to reset: unknown problem "{0}"'.format(err)) - msg += 'Failed to create a background task for resetting "{0}": problem not found.'.format(problem_url) + msg += '' + _u('Failed to create a background task for resetting "{0}": problem not found.').format(problem_url) + '' except Exception as err: log.error("Encountered exception from reset: {0}".format(err)) - msg += 'Failed to create a background task for resetting "{0}": {1}.'.format(problem_url, err.message) + msg += '' + _u('Failed to create a background task for resetting "{url}": {message}.').format(url = problem_url, message = err.message) + '' elif "Show Background Task History for Student" in action: # put this before the non-student case, since the use of "in" will cause this to be missed @@ -316,11 +316,9 @@ def get_student_from_identifier(unique_student_identifier): course_id=course_id, module_state_key=module_state_key ) - msg += "Found module. " + msg += _u("Found module. ") except StudentModule.DoesNotExist as err: - error_msg = "Couldn't find module with that urlname: {0}. ".format( - problem_urlname - ) + error_msg = _u("Couldn't find module with that urlname: {url}. ").format(url = problem_urlname) msg += "" + error_msg + "({0}) ".format(err) + "" log.debug(error_msg) @@ -329,7 +327,7 @@ def get_student_from_identifier(unique_student_identifier): # delete the state try: student_module.delete() - msg += "Deleted student module state for {0}!".format(module_state_key) + msg += "" + _u("Deleted student module state for {state}!").format(state = module_state_key) + "" event = { "problem": module_state_key, "student": unique_student_identifier, @@ -342,8 +340,8 @@ def get_student_from_identifier(unique_student_identifier): page="idashboard" ) except Exception as err: - error_msg = "Failed to delete module state for {0}/{1}. ".format( - unique_student_identifier, problem_urlname + error_msg = _u("Failed to delete module state for {id}/{url}. ").format( + id = unique_student_identifier, url = problem_urlname ) msg += "" + error_msg + "({0}) ".format(err) + "" log.exception(error_msg) @@ -365,10 +363,10 @@ def get_student_from_identifier(unique_student_identifier): "course": course_id } track.views.server_track(request, "reset-student-attempts", event, page="idashboard") - msg += "Module state successfully reset!" + msg += "" + _u("Module state successfully reset!") + "" except Exception as err: - error_msg = "Couldn't reset module state for {0}/{1}. ".format( - unique_student_identifier, problem_urlname + error_msg = _u("Couldn't reset module state for {id}/{url}. ").format( + id = unique_student_identifier, url = problem_urlname ) msg += "" + error_msg + "({0}) ".format(err) + "" log.exception(error_msg) @@ -377,13 +375,11 @@ def get_student_from_identifier(unique_student_identifier): try: instructor_task = submit_rescore_problem_for_student(request, course_id, module_state_key, student) if instructor_task is None: - msg += 'Failed to create a background task for rescoring "{0}" for student {1}.'.format(module_state_key, unique_student_identifier) + msg += '' + _u('Failed to create a background task for rescoring "{key}" for student {id}.').format(key = module_state_key, id = unique_student_identifier) + '' else: track.views.server_track(request, "rescore-student-submission", {"problem": module_state_key, "student": unique_student_identifier, "course": course_id}, page="idashboard") except Exception as err: - msg += 'Failed to create a background task for rescoring "{0}": {1}.'.format( - module_state_key, err.message - ) + msg += '' + _u('Failed to create a background task for rescoring "{key}": {id}.').format(key = module_state_key, id = err.message) + '' log.exception("Encountered exception from rescore: student '{0}' problem '{1}'".format( unique_student_identifier, module_state_key ) @@ -397,7 +393,7 @@ def get_student_from_identifier(unique_student_identifier): if student is not None: progress_url = reverse('student_progress', kwargs={'course_id': course_id, 'student_id': student.id}) track.views.server_track(request, "get-student-progress-page", {"student": unicode(student), "instructor": unicode(request.user), "course": course_id}, page="idashboard") - msg += " Progress page for username: {1} with email address: {2}.".format(progress_url, student.username, student.email) + msg += " ".format(progress_url) + _u("Progress page for username: {username} with email address: {email}").format(username = student.username, email = student.email) + "." #---------------------------------------- # export grades to remote gradebook @@ -411,7 +407,7 @@ def get_student_from_identifier(unique_student_identifier): allgrades = get_student_grade_summary_data(request, course, course_id, get_grades=True, use_offline=use_offline) assignments = [[x] for x in allgrades['assignments']] - datatable = {'header': ['Assignment Name']} + datatable = {'header': [_u('Assignment Name')]} datatable['data'] = assignments datatable['title'] = action @@ -435,27 +431,27 @@ def domatch(x): datatable = {} aname = request.POST.get('assignment_name', '') if not aname: - msg += "Please enter an assignment name" + msg += "" + _u("Please enter an assignment name") + "" else: allgrades = get_student_grade_summary_data(request, course, course_id, get_grades=True, use_offline=use_offline) if aname not in allgrades['assignments']: - msg += "Invalid assignment name '%s'" % aname + msg += "" + _u("Invalid assignment name '{name}'").format(name = aname) + "" else: aidx = allgrades['assignments'].index(aname) - datatable = {'header': ['External email', aname]} + datatable = {'header': [_u('External email'), aname]} ddata = [] for x in allgrades['students']: # do one by one in case there is a student who has only partial grades try: ddata.append([x.email, x.grades[aidx]]) except IndexError: - log.debug('No grade for assignment %s (%s) for student %s', aidx, aname, x.email) + log.debug('No grade for assignment {idx} ({name}) for student {email}'.format(idx = aidx, name = aname, email = x.email)) datatable['data'] = ddata - datatable['title'] = 'Grades for assignment "%s"' % aname + datatable['title'] = _u('Grades for assignment "{name}"').format(name = aname) if 'Export CSV' in action: # generate and return CSV file - return return_csv('grades %s.csv' % aname, datatable) + return return_csv('grades {name}.csv'.format(name = aname), datatable) elif 'remote gradebook' in action: file_pointer = StringIO() @@ -470,12 +466,12 @@ def domatch(x): elif 'List course staff' in action: role = CourseStaffRole(course.location) - datatable = _role_members_table(role, "List of Staff", course_id) + datatable = _role_members_table(role, _("List of Staff"), course_id) track.views.server_track(request, "list-staff", {}, page="idashboard") elif 'List course instructors' in action and GlobalStaff().has_user(request.user): role = CourseInstructorRole(course.location) - datatable = _role_members_table(role, "List of Instructors", course_id) + datatable = _role_members_table(role, _("List of Instructors"), course_id) track.views.server_track(request, "list-instructors", {}, page="idashboard") elif action == 'Add course staff': @@ -515,8 +511,8 @@ def getdat(u): return [u.username, u.email] + [getattr(p, x, '') for x in profkeys] datatable['data'] = [getdat(u) for u in enrolled_students] - datatable['title'] = 'Student profile data for course %s' % course_id - return return_csv('profiledata_%s.csv' % course_id, datatable) + datatable['title'] = _u('Student profile data for course {couse_id}').format(course_id = course_id) + return return_csv('profiledata_{course_id}.csv'.format(course_id = course_id), datatable) elif 'Download CSV of all responses to problem' in action: problem_to_dump = request.POST.get('problem_to_dump', '') @@ -529,17 +525,17 @@ def getdat(u): smdat = StudentModule.objects.filter(course_id=course_id, module_state_key=module_state_key) smdat = smdat.order_by('student') - msg += "Found %d records to dump " % len(smdat) + msg += _u("Found {num} records to dump ").format(num = smdat) except Exception as err: - msg += "Couldn't find module with that urlname. " - msg += "
    %s
    " % escape(err) + msg += "" + _u("Couldn't find module with that urlname.") + " " + msg += "
    {err}
    ".format(err = escape(err)) smdat = [] if smdat: datatable = {'header': ['username', 'state']} datatable['data'] = [[x.student.username, x.state] for x in smdat] - datatable['title'] = 'Student state for problem %s' % problem_to_dump - return return_csv('student_state_from_%s.csv' % problem_to_dump, datatable) + datatable['title'] = _u('Student state for problem {problem}').format(problem = problem_to_dump) + return return_csv('student_state_from_{problem}.csv'.format(problem = problem_to_dump), datatable) elif 'Download CSV of all student anonymized IDs' in action: students = User.objects.filter( @@ -555,7 +551,7 @@ def getdat(u): elif 'List beta testers' in action: role = CourseBetaTesterRole(course.location) - datatable = _role_members_table(role, "List of Beta Testers", course_id) + datatable = _role_members_table(role, _("List of Beta Testers"), course_id) track.views.server_track(request, "list-beta-testers", {}, page="idashboard") elif action == 'Add beta testers': @@ -694,9 +690,9 @@ def getdat(u): else: # If sending the task succeeds, deliver a success message to the user. if email_to_option == "all": - email_msg = '

    Your email was successfully queued for sending. Please note that for large classes, it may take up to an hour (or more, if other courses are simultaneously sending email) to send all emails.

    ' + email_msg = '

    ' + _u('Your email was successfully queued for sending. Please note that for large classes, it may take up to an hour (or more, if other courses are simultaneously sending email) to send all emails.') + '

    ' else: - email_msg = '

    Your email was successfully queued for sending.

    ' + email_msg = '

    ' + _u('Your email was successfully queued for sending.') + '

    ' elif "Show Background Email Task History" in action: message, datatable = get_background_task_table(course_id, task_type='bulk_course_email') @@ -853,17 +849,17 @@ def _do_remote_gradebook(user, course, action, args=None, files=None): ''' rg = course.remote_gradebook if not rg: - msg = "No remote gradebook defined in course metadata" + msg = _u("No remote gradebook defined in course metadata") return msg, {} rgurl = settings.MITX_FEATURES.get('REMOTE_GRADEBOOK_URL', '') if not rgurl: - msg = "No remote gradebook url defined in settings.MITX_FEATURES" + msg = _u("No remote gradebook url defined in settings.MITX_FEATURES") return msg, {} rgname = rg.get('name', '') if not rgname: - msg = "No gradebook name defined in course remote_gradebook metadata" + msg = _u("No gradebook name defined in course remote_gradebook metadata") return msg, {} if args is None: @@ -875,19 +871,19 @@ def _do_remote_gradebook(user, course, action, args=None, files=None): resp = requests.post(rgurl, data=data, verify=False, files=files) retdict = json.loads(resp.content) except Exception as err: - msg = "Failed to communicate with gradebook server at %s
    " % rgurl - msg += "Error: %s" % err - msg += "
    resp=%s" % resp.content - msg += "
    data=%s" % data + msg = _u("Failed to communicate with gradebook server at {url}").format(url = rgurl) + "
    " + msg += _u("Error: {err}").format(err = err) + msg += "
    resp={resp}".format(resp = resp.content) + msg += "
    data={data}".format(data = data) return msg, {} - msg = '
    %s
    ' % retdict['msg'].replace('\n', '
    ') + msg = '
    {msg}
    '.format(msg = retdict['msg'].replace('\n', '
    ')) retdata = retdict['data'] # a list of dicts if retdata: datatable = {'header': retdata[0].keys()} datatable['data'] = [x.values() for x in retdata] - datatable['title'] = 'Remote gradebook response for %s' % action + datatable['title'] = _u('Remote gradebook response for {action}').format(action = action) datatable['retdata'] = retdata else: datatable = {} @@ -906,13 +902,13 @@ def _list_course_forum_members(course_id, rolename, datatable): Returns message status string to append to displayed message, if role is unknown. """ # make sure datatable is set up properly for display first, before checking for errors - datatable['header'] = ['Username', 'Full name', 'Roles'] - datatable['title'] = 'List of Forum {0}s in course {1}'.format(rolename, course_id) + datatable['header'] = [_u('Username'), _u('Full name'), _u('Roles')] + datatable['title'] = _u('List of Forum {name}s in course {id}').format(name = rolename, id = course_id) datatable['data'] = [] try: role = Role.objects.get(name=rolename, course_id=course_id) except Role.DoesNotExist: - return 'Error: unknown rolename "{0}"'.format(rolename) + return '' + _u('Error: unknown rolename "{0}"').format(rolename) + '' uset = role.users.all().order_by('username') msg = 'Role = {0}'.format(rolename) log.debug('role={0}'.format(rolename)) @@ -936,11 +932,11 @@ def _update_forum_role_membership(uname, course, rolename, add_or_remove): try: user = User.objects.get(username=uname) except User.DoesNotExist: - return 'Error: unknown username "{0}"'.format(uname) + return '' + _u('Error: unknown username "{0}"').format(uname) + '' try: role = Role.objects.get(name=rolename, course_id=course.id) except Role.DoesNotExist: - return 'Error: unknown rolename "{0}"'.format(rolename) + return '' + _u('Error: unknown rolename "{0}"').format(rolename) + '' # check whether role already has the specified user: alreadyexists = role.users.filter(username=uname).exists() @@ -948,19 +944,19 @@ def _update_forum_role_membership(uname, course, rolename, add_or_remove): log.debug('rolename={0}'.format(rolename)) if add_or_remove == FORUM_ROLE_REMOVE: if not alreadyexists: - msg = 'Error: user "{0}" does not have rolename "{1}", cannot remove'.format(uname, rolename) + msg = '' + _u('Error: user "{0}" does not have rolename "{1}", cannot remove').format(uname, rolename) + '' else: user.roles.remove(role) - msg = 'Removed "{0}" from "{1}" forum role = "{2}"'.format(user, course.id, rolename) + msg = '' + _u('Removed "{0}" from "{1}" forum role = "{2}"').format(user, course.id, rolename) + '' else: if alreadyexists: - msg = 'Error: user "{0}" already has rolename "{1}", cannot add'.format(uname, rolename) + msg = '' + _u('Error: user "{0}" already has rolename "{1}", cannot add').format(uname, rolename) + '' else: if (rolename == FORUM_ROLE_ADMINISTRATOR and not has_access(user, course, 'staff')): - msg = 'Error: user "{0}" should first be added as staff before adding as a forum administrator, cannot add'.format(uname) + msg = '' + _u('Error: user "{0}" should first be added as staff before adding as a forum administrator, cannot add').format(uname) + '' else: user.roles.add(role) - msg = 'Added "{0}" to "{1}" forum role = "{2}"'.format(user, course.id, rolename) + msg = '' + _u('Added "{0}" to "{1}" forum role = "{2}"').format(user, course.id, rolename) + '' return msg @@ -980,9 +976,9 @@ def _role_members_table(role, title, course_id): 'title': "{title} in course {course}" """ uset = role.users_with_role() - datatable = {'header': ['Username', 'Full name']} + datatable = {'header': [_u('Username'), _u('Full name')]} datatable['data'] = [[x.username, x.profile.name] for x in uset] - datatable['title'] = '{0} in course {1}'.format(title, course_id) + datatable['title'] = _u('{0} in course {1}').format(title, course_id) return datatable @@ -1105,7 +1101,7 @@ def get_student_grade_summary_data(request, course, course_id, get_grades=True, courseenrollment__is_active=1, ).prefetch_related("groups").order_by('username') - header = ['ID', 'Username', 'Full Name', 'edX email', 'External email'] + header = [_u('ID'), _u('Username'), _u('Full Name'), _u('edX email'), _u('External email')] assignments = [] if get_grades and enrolled_students.count() > 0: # just to construct the header @@ -1290,7 +1286,7 @@ def _do_enroll_students(course, course_id, students, overload=False, auto_enroll datatable = {'header': ['StudentEmail', 'action']} datatable['data'] = [[x, status[x]] for x in sorted(status)] - datatable['title'] = 'Enrollment of students' + datatable['title'] = _u('Enrollment of students') def sf(stat): return [x for x in status if status[x] == stat] @@ -1363,7 +1359,7 @@ def _do_unenroll_students(course_id, students, email_students=False): datatable = {'header': ['StudentEmail', 'action']} datatable['data'] = [[x, status[x]] for x in sorted(status)] - datatable['title'] = 'Un-enrollment of students' + datatable['title'] = _u('Un-enrollment of students') data = dict(datatable=datatable) return data @@ -1546,10 +1542,10 @@ def get_background_task_table(course_id, problem_url=None, student=None, task_ty if problem_url is None: msg += 'Failed to find any background tasks for course "{course}".'.format(course=course_id) elif student is not None: - template = 'Failed to find any background tasks for course "{course}", module "{problem}" and student "{student}".' + template = '' + _u('Failed to find any background tasks for course "{course}", module "{problem}" and student "{student}".') + '' msg += template.format(course=course_id, problem=problem_url, student=student.username) else: - msg += 'Failed to find any background tasks for course "{course}" and module "{problem}".'.format(course=course_id, problem=problem_url) + msg += '' + _u('Failed to find any background tasks for course "{course}" and module "{problem}".').format(course=course_id, problem=problem_url) + '' else: datatable['header'] = ["Task Type", "Task Id", diff --git a/lms/static/coffee/src/staff_grading/staff_grading.coffee b/lms/static/coffee/src/staff_grading/staff_grading.coffee index 80487f24ee34..db474f6da47f 100644 --- a/lms/static/coffee/src/staff_grading/staff_grading.coffee +++ b/lms/static/coffee/src/staff_grading/staff_grading.coffee @@ -189,7 +189,6 @@ class @StaffGrading $(window).keyup @keyup_handler @question_header = $('.question-header') @question_header.click @collapse_question - @collapse_question() # model state @state = state_no_data @@ -296,7 +295,7 @@ class @StaffGrading submission_id: @submission_id location: @location submission_flagged: @flag_submission_checkbox.is(':checked') - @gentle_alert "Grades saved. Fetching the next submission to grade." + @gentle_alert gettext("Grades saved. Fetching the next submission to grade.") @backend.post('save_grade', data, @ajax_callback) gentle_alert: (msg) => @@ -344,11 +343,11 @@ class @StaffGrading # clear the problem list and breadcrumbs @problem_list.html(''' - Problem Name - Graded - Available to Grade - Required - Progress + ''' + gettext("Problem Name") + ''' + ''' + gettext("Graded") + ''' + ''' + gettext("Available to Grade") + ''' + ''' + gettext("Required") + ''' + ''' + gettext("Progress") + ''' ''') @breadcrumbs.html('') @@ -410,7 +409,7 @@ class @StaffGrading show_action_button = true problem_list_link = $('').attr('href', 'javascript:void(0);') - .append("< Back to problem list") + .append("< " + gettext("Back to problem list")) .click => @get_problem_list() # set up the breadcrumbing @@ -418,15 +417,15 @@ class @StaffGrading if @state == state_error - @set_button_text('Try loading again') + @set_button_text(gettext('Try loading again')) show_action_button = true else if @state == state_grading @ml_error_info_container.html(@ml_error_info) meta_list = $("
    ") - meta_list.append("
    #{@num_pending} available |
    ") - meta_list.append("
    #{@num_graded} graded |
    ") - meta_list.append("
    #{Math.max(@min_for_ml - @num_graded, 0)} more needed to start ML

    ") + meta_list.append("
    #{@num_pending} " + gettext('available') + " |
    ") + meta_list.append("
    #{@num_graded} " + gettext('graded') + " |
    ") + meta_list.append("
    #{Math.max(@min_for_ml - @num_graded, 0)} " + gettext('more needed to start ML') + "

    ") @problem_meta_info.html(meta_list) @prompt_container.html(@prompt) @@ -439,15 +438,15 @@ class @StaffGrading @setup_score_selection() else if @state == state_graded - @set_button_text('Submit') + @set_button_text(gettext('Submit')) show_action_button = false else if @state == state_no_data @message_container.html(@message) - @set_button_text('Re-check for submissions') + @set_button_text(gettext('Re-check for submissions')) else - @error('System got into invalid state ' + @state) + @error(gettext('System got into invalid state ') + @state) @submit_button.toggle(show_submit_button) @action_button.toggle(show_action_button) @@ -462,17 +461,17 @@ class @StaffGrading else if @state == state_no_data @get_next_submission(@location) else - @error('System got into invalid state for submission: ' + @state) + @error(gettext('System got into invalid state for submission: ') + @state) collapse_question: () => @prompt_container.slideToggle() @prompt_container.toggleClass('open') - if @question_header.text() == "(Hide)" + if @question_header.text() == gettext("(Hide)") Logger.log 'staff_grading_hide_question', {location: @location} - new_text = "(Show)" + new_text = gettext("(Show)") else Logger.log 'staff_grading_show_question', {location: @location} - new_text = "(Hide)" + new_text = gettext("(Hide)") @question_header.text(new_text) scroll_to_top: () => diff --git a/lms/templates/combinedopenended/combined_open_ended.html b/lms/templates/combinedopenended/combined_open_ended.html index c8f4c029dc7f..5b0f94f6bb09 100644 --- a/lms/templates/combinedopenended/combined_open_ended.html +++ b/lms/templates/combinedopenended/combined_open_ended.html @@ -58,7 +58,7 @@

    ${display_name}

    % if is_staff:
    - Staff Warning: Please note that if you submit a duplicate of text that has already been submitted for grading, it will not show up in the staff grading view. It will be given the same grade that the original received automatically, and will be returned within 30 minutes if the original is already graded, or when the original is graded if not. + ${_("Staff Warning: Please note that if you submit a duplicate of text that has already been submitted for grading, it will not show up in the staff grading view. It will be given the same grade that the original received automatically, and will be returned within 30 minutes if the original is already graded, or when the original is graded if not.")}
    % endif diff --git a/lms/templates/combinedopenended/openended/open_ended_rubric.html b/lms/templates/combinedopenended/openended/open_ended_rubric.html index 1d73647ec761..8cc30779b2ce 100644 --- a/lms/templates/combinedopenended/openended/open_ended_rubric.html +++ b/lms/templates/combinedopenended/openended/open_ended_rubric.html @@ -1,4 +1,5 @@ <%! from django.utils.translation import ugettext as _ %> +<%! from django.utils.translation import ungettext%> <% from random import randint %>
    @@ -6,7 +7,7 @@
    ${_("Rubric")}
    -

    Select the criteria you feel best represents this submission in each category.

    +

    ${_("Select the criteria you feel best represents this submission in each category.")}

    % for i in range(len(categories)): <% category = categories[i] %> @@ -22,7 +23,7 @@ % endif % endfor diff --git a/lms/templates/courseware/course_navigation.html b/lms/templates/courseware/course_navigation.html index 0be247ed899c..05189edfd15a 100644 --- a/lms/templates/courseware/course_navigation.html +++ b/lms/templates/courseware/course_navigation.html @@ -1,4 +1,5 @@ ## mako +<%! from django.utils.translation import ugettext as _ %> <%page args="active_page=None" /> <% diff --git a/lms/templates/courseware/gradebook.html b/lms/templates/courseware/gradebook.html index 8828721555de..4b1175590b90 100644 --- a/lms/templates/courseware/gradebook.html +++ b/lms/templates/courseware/gradebook.html @@ -45,7 +45,7 @@

    ${_("Gradebook")}

    - + diff --git a/lms/templates/courseware/progress.html b/lms/templates/courseware/progress.html index 1c099119c0cd..6cb80e43e228 100644 --- a/lms/templates/courseware/progress.html +++ b/lms/templates/courseware/progress.html @@ -59,7 +59,7 @@

    - ${"{0:.3n} of {1:.3n} possible points".format( float(earned), float(total) )} + ${_("{earned:.3n} of {total:.3n} possible points").format( earned = float(earned), total = float(total) )} %endif %if total > 0 or earned > 0: @@ -72,7 +72,7 @@

    %if len(section['scores']) > 0: -

    ${ "Problem Scores: " if section['graded'] else "Practice Scores: "}

    +

    ${ _("Problem Scores: ") if section['graded'] else _("Practice Scores: ")}

      %for score in section['scores']:
    1. ${"{0:.3n}/{1:.3n}".format(float(score.earned),float(score.possible))}
    2. diff --git a/lms/templates/discussion/_discussion_module.html b/lms/templates/discussion/_discussion_module.html index 37f8052520b2..09dd9d06d8f5 100644 --- a/lms/templates/discussion/_discussion_module.html +++ b/lms/templates/discussion/_discussion_module.html @@ -2,6 +2,6 @@ <%include file="_underscore_templates.html" />
      diff --git a/lms/templates/discussion/_filter_dropdown.html b/lms/templates/discussion/_filter_dropdown.html index c70fcb47cf88..b108be6d2e09 100644 --- a/lms/templates/discussion/_filter_dropdown.html +++ b/lms/templates/discussion/_filter_dropdown.html @@ -27,7 +27,7 @@
      • diff --git a/lms/templates/discussion/_inline_new_post.html b/lms/templates/discussion/_inline_new_post.html index 69c557b2bb7a..001cdb25d20a 100644 --- a/lms/templates/discussion/_inline_new_post.html +++ b/lms/templates/discussion/_inline_new_post.html @@ -36,7 +36,7 @@
        - +
        diff --git a/lms/templates/discussion/_new_post.html b/lms/templates/discussion/_new_post.html index dfc942730b74..9662889e5aab 100644 --- a/lms/templates/discussion/_new_post.html +++ b/lms/templates/discussion/_new_post.html @@ -67,7 +67,7 @@
          - +
          diff --git a/lms/templates/discussion/_thread_list_template.html b/lms/templates/discussion/_thread_list_template.html index 208c2b014d95..6670883ffe1d 100644 --- a/lms/templates/discussion/_thread_list_template.html +++ b/lms/templates/discussion/_thread_list_template.html @@ -22,7 +22,7 @@
          diff --git a/lms/templates/discussion/_underscore_templates.html b/lms/templates/discussion/_underscore_templates.html index 9d7d150cf257..e98c21c95904 100644 --- a/lms/templates/discussion/_underscore_templates.html +++ b/lms/templates/discussion/_underscore_templates.html @@ -31,8 +31,8 @@

          ${_("Post a response:")}

          ${"<%- obj.group_string%>"}
          ${"<% } %>"} - - + ${'<%- votes["up_count"] %>'}votes (click to vote) + + + ${'<%- votes["up_count"] %>'}${_("votes (click to vote)")}

          ${'<%- title %>'}

          ${"<% if (obj.username) { %>"} @@ -44,7 +44,7 @@

          ${'<%- title %>'}

          ${_("• This thread is closed.")}

          - + ${_("Follow this post")} @@ -55,12 +55,12 @@

          ${'<%- title %>'}

          % if course and has_permission(user, 'openclose_thread', course.id): -
          +
          ${_("Pin Thread")}
          %else: ${"<% if (pinned) { %>"} -
          +
          ${_("Pin Thread")}
          ${"<% } %>"} % endif @@ -68,7 +68,7 @@

          ${'<%- title %>'}

          ${'<% if (obj.courseware_url) { %>'}
          - (this post is about ${'<%- courseware_title %>'}) + (${_("this post is about ")}${'<%- courseware_title %>'})
          ${'<% } %>'} @@ -86,7 +86,7 @@

          ${_("Editing post")}

            - "}" placeholder="Title"> +
            ${"<%- body %>"}
            @@ -97,7 +97,7 @@

            ${_("Editing post")}

            ## ## "}"> ##
            - + ${_("Cancel")}
            @@ -111,7 +111,7 @@

            ${_("Editing post")}

              + data-placeholder="${_('Add a comment...')}">
              ${_("Submit")}
              @@ -123,11 +123,11 @@

              ${_("Editing post")}

              @@ -180,7 +180,7 @@

              ${_("Editing response")}