diff --git a/common/djangoapps/django_comment_common/models.py b/common/djangoapps/django_comment_common/models.py index c345f26919..9c71c12561 100644 --- a/common/djangoapps/django_comment_common/models.py +++ b/common/djangoapps/django_comment_common/models.py @@ -5,16 +5,16 @@ from django.contrib.auth.models import User from django.dispatch import receiver from django.db.models.signals import post_save - +from django.utils.translation import ugettext_noop from student.models import CourseEnrollment 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' +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/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index 12cdf58b2e..63a7f9a8a2 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -197,7 +197,7 @@ def create_comment(request, course_id, thread_id): """ if cc_settings.MAX_COMMENT_DEPTH is not None: if cc_settings.MAX_COMMENT_DEPTH < 0: - return JsonError("Comment level too deep") + return JsonError(_("Comment level too deep")) return _create_comment(request, course_id, thread_id=thread_id) @@ -273,7 +273,7 @@ def create_sub_comment(request, course_id, comment_id): """ if cc_settings.MAX_COMMENT_DEPTH is not None: if cc_settings.MAX_COMMENT_DEPTH <= cc.Comment.find(comment_id).depth: - return JsonError("Comment level too deep") + return JsonError(_("Comment level too deep")) return _create_comment(request, course_id, parent_id=comment_id) @@ -579,7 +579,7 @@ def upload(request, course_id): # ajax upload file to a question or answer error = _('Error uploading file. Please contact the site administrator. Thank you.') if error == '': - result = 'Good' + result = _('Good') file_url = file_storage.url(new_file_name) parsed_url = urlparse.urlparse(file_url) file_url = urlparse.urlunparse( diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index fc405923fe..d6a84566e2 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -131,7 +131,7 @@ def inline_discussion(request, course_id, discussion_id): cohorts_list = list() if is_cohorted: - cohorts_list.append({'name': 'All Groups', 'id': None}) + cohorts_list.append({'name': _('All Groups'), 'id': None}) #if you're a mod, send all cohorts and let you pick @@ -309,7 +309,7 @@ def single_thread(request, course_id, discussion_id, thread_id): 'cohorted_commentables': cohorted_commentables } - return render_to_response('discussion/single_thread.html', context) + return render_to_response('discussion/index.html', context) @login_required diff --git a/lms/djangoapps/django_comment_client/helpers.py b/lms/djangoapps/django_comment_client/helpers.py index b9f144e76c..2a045d27fd 100644 --- a/lms/djangoapps/django_comment_client/helpers.py +++ b/lms/djangoapps/django_comment_client/helpers.py @@ -9,18 +9,6 @@ import pystache_custom as pystache import urllib import os -# This method is used to pluralize the words "discussion" and "comment" -# when referring to how many discussion threads or comments the user -# has contributed to. - - -def pluralize(singular_term, count): - if int(count) >= 2 or int(count) == 0: - return singular_term + 's' - return singular_term - -# TODO there should be a better way to handle this - def include_mustache_templates(): mustache_dir = settings.PROJECT_ROOT / 'templates' / 'discussion' / 'mustache' @@ -31,3 +19,4 @@ def include_mustache_templates(): file_contents = map(read_file, filter(valid_file_name, os.listdir(mustache_dir))) return '\n'.join(map(wrap_in_tag, map(strip_file_name, file_contents))) + diff --git a/lms/djangoapps/django_comment_client/mustache_helpers.py b/lms/djangoapps/django_comment_client/mustache_helpers.py index c116de69c1..cfda1c7a1d 100644 --- a/lms/djangoapps/django_comment_client/mustache_helpers.py +++ b/lms/djangoapps/django_comment_client/mustache_helpers.py @@ -1,3 +1,4 @@ +from django.utils.translation import ugettext as _ import django.core.urlresolvers as urlresolvers import sys import inspect @@ -21,9 +22,9 @@ def url_for_user(content, user_id): def close_thread_text(content): if content.get('closed'): - return 'Re-open thread' + return _('Re-open thread') else: - return 'Close thread' + return _('Close thread') current_module = sys.modules[__name__] all_functions = inspect.getmembers(current_module, inspect.isfunction) diff --git a/lms/djangoapps/django_comment_client/tests/test_helpers.py b/lms/djangoapps/django_comment_client/tests/test_helpers.py deleted file mode 100644 index 6ca9680052..0000000000 --- a/lms/djangoapps/django_comment_client/tests/test_helpers.py +++ /dev/null @@ -1,12 +0,0 @@ -from django.test import TestCase - -from django_comment_client.helpers import pluralize - - -class PluralizeTestCase(TestCase): - - def testPluralize(self): - self.term = "cat" - self.assertEqual(pluralize(self.term, 0), "cats") - self.assertEqual(pluralize(self.term, 1), "cat") - self.assertEqual(pluralize(self.term, 2), "cats") diff --git a/lms/templates/discussion/_discussion_module.html b/lms/templates/discussion/_discussion_module.html index 00f6c94801..b95bce1f07 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 c70fcb47cf..b108be6d2e 100644 --- a/lms/templates/discussion/_filter_dropdown.html +++ b/lms/templates/discussion/_filter_dropdown.html @@ -27,7 +27,7 @@