Skip to content

Commit

Permalink
fix: ugetext and ngettext deprecation warnings (#33097)
Browse files Browse the repository at this point in the history
  • Loading branch information
irtazaakram authored Aug 25, 2023
1 parent e88f4e4 commit 0c46334
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions cms/djangoapps/contentstore/tests/test_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def __exit__(self, _type, _value, _traceback):
# Check that the old ugettext has been put back into place
self.assertEqual(i18n_service.ugettext(self.test_language), 'dummy language')

@mock.patch('django.utils.translation.ugettext', mock.Mock(return_value='XYZ-TEST-LANGUAGE'))
@mock.patch('django.utils.translation.gettext', mock.Mock(return_value='XYZ-TEST-LANGUAGE'))
def test_django_translator_in_use_with_empty_block(self):
"""
Expand All @@ -127,7 +126,7 @@ def test_django_translator_in_use_with_empty_block(self):
i18n_service = XBlockI18nService(None)
self.assertEqual(i18n_service.ugettext(self.test_language), 'XYZ-TEST-LANGUAGE')

@mock.patch('django.utils.translation.ugettext', mock.Mock(return_value='XYZ-TEST-LANGUAGE'))
@mock.patch('django.utils.translation.gettext', mock.Mock(return_value='XYZ-TEST-LANGUAGE'))
def test_message_catalog_translations(self):
"""
Test: Message catalog from FakeTranslation should return required translations.
Expand Down
2 changes: 1 addition & 1 deletion lms/templates/dashboard/_dashboard_course_listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.utils.http import urlencode
from urllib.parse import quote_plus
from django.utils.translation import gettext as _
from django.utils.translation import ungettext
from django.utils.translation import ngettext
from django.urls import reverse
from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.course_modes.helpers import enrollment_mode_display
Expand Down
6 changes: 3 additions & 3 deletions lms/templates/discussion/_user_profile.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<%! from django.utils.translation import gettext as _, ungettext %>
<%! from django.utils.translation import gettext as _, ngettext %>
<%def name="span(num)"><span>${num}</span></%def>
<div class="user-profile">
<div class="sidebar-username"><a class="learner-profile-link" href="${learner_profile_page_url}">${django_user.username | h}</a></div>
<div class="sidebar-user-roles">
${", ".join(_(role_name) for role_name in django_user_roles)}
</div>
<div class="sidebar-threads-count">${ungettext('%s discussion started', '%s discussions started', profiled_user['threads_count']) % span(profiled_user['threads_count']) | h}</div>
<div class="sidebar-comments-count">${ungettext('%s comment', '%s comments', profiled_user['comments_count']) % span(profiled_user['comments_count']) | h}</div>
<div class="sidebar-threads-count">${ngettext('%s discussion started', '%s discussions started', profiled_user['threads_count']) % span(profiled_user['threads_count']) | h}</div>
<div class="sidebar-comments-count">${ngettext('%s comment', '%s comments', profiled_user['comments_count']) % span(profiled_user['comments_count']) | h}</div>
</div>

0 comments on commit 0c46334

Please sign in to comment.