Commit b70bd2be by Sarina Canelake

Use ngettext rather than "word(s)" for plural phrases

parent c68fce1f
...@@ -23,6 +23,7 @@ from django.db import IntegrityError, transaction ...@@ -23,6 +23,7 @@ from django.db import IntegrityError, transaction
from django.http import (HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, from django.http import (HttpResponse, HttpResponseBadRequest, HttpResponseForbidden,
Http404) Http404)
from django.shortcuts import redirect from django.shortcuts import redirect
from django.utils.translation import ungettext
from django_future.csrf import ensure_csrf_cookie from django_future.csrf import ensure_csrf_cookie
from django.utils.http import cookie_date, base36_to_int from django.utils.http import cookie_date, base36_to_int
from django.utils.translation import ugettext as _, get_language from django.utils.translation import ugettext as _, get_language
...@@ -1511,14 +1512,21 @@ def password_reset_confirm_wrapper( ...@@ -1511,14 +1512,21 @@ def password_reset_confirm_wrapper(
num_distinct = settings.ADVANCED_SECURITY_CONFIG['MIN_DIFFERENT_STAFF_PASSWORDS_BEFORE_REUSE'] num_distinct = settings.ADVANCED_SECURITY_CONFIG['MIN_DIFFERENT_STAFF_PASSWORDS_BEFORE_REUSE']
else: else:
num_distinct = settings.ADVANCED_SECURITY_CONFIG['MIN_DIFFERENT_STUDENT_PASSWORDS_BEFORE_REUSE'] num_distinct = settings.ADVANCED_SECURITY_CONFIG['MIN_DIFFERENT_STUDENT_PASSWORDS_BEFORE_REUSE']
err_msg = _("You are re-using a password that you have used recently. You must " err_msg = ungettext(
"have {0} distinct password(s) before reusing a previous password.").format(num_distinct) "You are re-using a password that you have used recently. You must have {num} distinct password before reusing a previous password.",
"You are re-using a password that you have used recently. You must have {num} distinct passwords before reusing a previous password.",
num_distinct
).format(num=num_distinct)
# also, check to see if passwords are getting reset too frequent # also, check to see if passwords are getting reset too frequent
if PasswordHistory.is_password_reset_too_soon(user): if PasswordHistory.is_password_reset_too_soon(user):
num_days = settings.ADVANCED_SECURITY_CONFIG['MIN_TIME_IN_DAYS_BETWEEN_ALLOWED_RESETS'] num_days = settings.ADVANCED_SECURITY_CONFIG['MIN_TIME_IN_DAYS_BETWEEN_ALLOWED_RESETS']
err_msg = _("You are resetting passwords too frequently. Due to security policies, " err_msg = ungettext(
"{0} day(s) must elapse between password resets").format(num_days) # Translators: If you need to use a variable number instead of the number "one", use {num} in its place.
"You are resetting passwords too frequently. Due to security policies, one day must elapse between password resets",
"You are resetting passwords too frequently. Due to security policies, {num} days must elapse between password resets",
num_days
).format(num=num_days)
if err_msg: if err_msg:
# We have an password reset attempt which violates some security policy, use the # We have an password reset attempt which violates some security policy, use the
......
...@@ -703,7 +703,7 @@ class FileSubmission(InputTypeBase): ...@@ -703,7 +703,7 @@ class FileSubmission(InputTypeBase):
pull queue_len from the msg field. (TODO: get rid of the queue_len hack). pull queue_len from the msg field. (TODO: get rid of the queue_len hack).
""" """
_ = self.capa_system.i18n.ugettext _ = self.capa_system.i18n.ugettext
submitted_msg = _("Your file(s) have been submitted. As soon as your submission is" submitted_msg = _("Your files have been submitted. As soon as your submission is"
" graded, this message will be replaced with the grader's feedback.") " graded, this message will be replaced with the grader's feedback.")
self.submitted_msg = submitted_msg self.submitted_msg = submitted_msg
......
<h2 class="problem-header">${_("Problem Header")}</h2> <h2 class="problem-header">Problem Header</h2>
<div class='problem-progress'></div> <div class='problem-progress'></div>
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
<span id="display_example_1"></span> <span id="display_example_1"></span>
<span id="input_example_1_dynamath"></span> <span id="input_example_1_dynamath"></span>
<input class="check" type="button" value="${_('Check')}"> <input class="check" type="button" value="Check">
<input class="reset" type="button" value="${_('Reset')}"> <input class="reset" type="button" value="Reset">
<input class="save" type="button" value="${_('Save')}"> <input class="save" type="button" value="Save">
<button class="show"><span class="show-label">${_("Show Answer(s)")}</span> <span class="sr">(for question(s) above - adjacent to each field)</span></button> <button class="show"><span class="show-label">Show Answer(s)</span> <span class="sr">(for question(s) above - adjacent to each field)</span></button>
<a href="/courseware/6.002_Spring_2012/${ explain }" class="new-page">${_("Explanation")}</a> <a href="/courseware/6.002_Spring_2012/${ explain }" class="new-page">Explanation</a>
<div class="submission_feedback"></div> <div class="submission_feedback"></div>
</div> </div>
</div> </div>
...@@ -236,7 +236,7 @@ class TestGetProblemGradeDistribution(ModuleStoreTestCase): ...@@ -236,7 +236,7 @@ class TestGetProblemGradeDistribution(ModuleStoreTestCase):
def test_get_students_opened_subsection_csv(self): def test_get_students_opened_subsection_csv(self):
tooltip = '4162 student(s) opened Subsection 5: Relational Algebra Exercises' tooltip = '4162 students opened Subsection 5: Relational Algebra Exercises'
attributes = '?module_id=' + self.item.location.to_deprecated_string() + '&tooltip=' + tooltip + '&csv=true' attributes = '?module_id=' + self.item.location.to_deprecated_string() + '&tooltip=' + tooltip + '&csv=true'
request = self.request_factory.get(reverse('get_students_opened_subsection') + attributes) request = self.request_factory.get(reverse('get_students_opened_subsection') + attributes)
......
...@@ -154,7 +154,7 @@ class TestPasswordHistory(LoginEnrollmentTestCase): ...@@ -154,7 +154,7 @@ class TestPasswordHistory(LoginEnrollmentTestCase):
student_email, _ = self._setup_user() student_email, _ = self._setup_user()
user = User.objects.get(email=student_email) user = User.objects.get(email=student_email)
err_msg = 'You are re-using a password that you have used recently. You must have 1 distinct password(s)' err_msg = 'You are re-using a password that you have used recently. You must have 1 distinct password'
success_msg = 'Your Password Reset is Complete' success_msg = 'Your Password Reset is Complete'
token = default_token_generator.make_token(user) token = default_token_generator.make_token(user)
...@@ -190,7 +190,7 @@ class TestPasswordHistory(LoginEnrollmentTestCase): ...@@ -190,7 +190,7 @@ class TestPasswordHistory(LoginEnrollmentTestCase):
staff_email, _ = self._setup_user(is_staff=True) staff_email, _ = self._setup_user(is_staff=True)
user = User.objects.get(email=staff_email) user = User.objects.get(email=staff_email)
err_msg = 'You are re-using a password that you have used recently. You must have 2 distinct password(s)' err_msg = 'You are re-using a password that you have used recently. You must have 2 distinct passwords'
success_msg = 'Your Password Reset is Complete' success_msg = 'Your Password Reset is Complete'
token = default_token_generator.make_token(user) token = default_token_generator.make_token(user)
......
...@@ -351,15 +351,19 @@ edx_d3CreateStackedBarGraph = function(parameters, svg, divTooltip) { ...@@ -351,15 +351,19 @@ edx_d3CreateStackedBarGraph = function(parameters, svg, divTooltip) {
// Construct the tooltip // Construct the tooltip
if (d.tooltip['type'] == 'subsection') { if (d.tooltip['type'] == 'subsection') {
tooltip_str = d.tooltip['num_students'] + ' ' + gettext('student(s) opened Subsection') + ' ' \ stud_str = ngettext('%(num_students)s student opened Subsection', '%(num_students)s students opened Subsection', d.tooltip['num_students']);
+ d.tooltip['subsection_num'] + ': ' + d.tooltip['subsection_name'] stud_str = interpolate(stud_str, {'num_students': d.tooltip['num_students']}, true);
tooltip_str = stud_str + ' ' + d.tooltip['subsection_num'] + ': ' + d.tooltip['subsection_name'];
}else if (d.tooltip['type'] == 'problem') { }else if (d.tooltip['type'] == 'problem') {
stud_str = ngettext('%(num_students)s student', '%(num_students)s students', d.tooltip['count_grade']);
stud_str = interpolate(stud_str, {'num_students': d.tooltip['count_grade']}, true);
q_str = ngettext('%(num_questions)s question', '%(num_questions)s questions', d.tooltip['max_grade']);
q_str = interpolate(q_str, {'num_questions': d.tooltip['max_grade']}, true);
tooltip_str = d.tooltip['label'] + ' ' + d.tooltip['problem_name'] + ' - ' \ tooltip_str = d.tooltip['label'] + ' ' + d.tooltip['problem_name'] + ' - ' \
+ d.tooltip['count_grade'] + ' ' + gettext('students') + ' (' \ + stud_str + ' (' + d.tooltip['student_count_percent'] + '%) (' \
+ d.tooltip['student_count_percent'] + '%) (' + \ + d.tooltip['percent'] + '%: ' + d.tooltip['grade'] +'/' \
+ d.tooltip['percent'] + '%: ' + \ + q_str + ')';
+ d.tooltip['grade'] +'/' + d.tooltip['max_grade'] + ' '
+ gettext('questions') + ')'
} }
graph.divTooltip.style("visibility", "visible") graph.divTooltip.style("visibility", "visible")
.text(tooltip_str); .text(tooltip_str);
...@@ -438,4 +442,4 @@ edx_d3CreateStackedBarGraph = function(parameters, svg, divTooltip) { ...@@ -438,4 +442,4 @@ edx_d3CreateStackedBarGraph = function(parameters, svg, divTooltip) {
}; };
return graph; return graph;
}; };
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment