Skip to content

Commit

Permalink
Change ugettext functions to the gettext ones
Browse files Browse the repository at this point in the history
The ugettext functions are intended for Python 2 because
it has separate string and Unicode string types.
Python 3 has only Unicode strings and a separate byte array type.

From the Django 3.0 release notes:
https://docs.djangoproject.com/en/3.0/releases/3.0/#id3

django.utils.translation.ugettext(), ugettext_lazy(),
ugettext_noop(), ungettext(), and ungettext_lazy() are deprecated
in favor of the functions that they're aliases for:
django.utils.translation.gettext(), gettext_lazy(),
gettext_noop(), ngettext(), and ngettext_lazy().
  • Loading branch information
markkuriekkinen committed Feb 9, 2021
1 parent de03d68 commit b965b76
Show file tree
Hide file tree
Showing 44 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion aplus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# You can copy local_settings.example.py and start from there.
##
from os.path import abspath, dirname, join
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
BASE_DIR = dirname(dirname(abspath(__file__)))


Expand Down
2 changes: 1 addition & 1 deletion apps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from django.db import models
from django.template import loader
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
import feedparser

from apps.app_renderers import ExternalIFramePluginRenderer, \
Expand Down
2 changes: 1 addition & 1 deletion authorization/permissions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.utils.text import format_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from lib.helpers import Enum

Expand Down
2 changes: 1 addition & 1 deletion course/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from course.models import (
Course,
Expand Down
2 changes: 1 addition & 1 deletion course/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django import forms
from django.contrib.humanize.templatetags.humanize import ordinal
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from aplus.api import api_reverse
from lib.fields import UsersSearchSelectField
Expand Down
2 changes: 1 addition & 1 deletion course/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from django.utils import timezone
from django.utils.functional import cached_property
from django.utils.text import format_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django_colortag.models import ColorTag

from apps.models import BaseTab, BasePlugin
Expand Down
2 changes: 1 addition & 1 deletion course/permissions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.http import Http404
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from authorization.permissions import (
ACCESS,
Expand Down
2 changes: 1 addition & 1 deletion course/staff_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.contrib import messages
from django.shortcuts import get_object_or_404
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from authorization.permissions import ACCESS
from lib.helpers import settings_text
Expand Down
2 changes: 1 addition & 1 deletion course/viewbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.http import Http404
from django.shortcuts import get_object_or_404, render_to_response
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.translation import get_language, get_language_info

from authorization.permissions import ACCESS
Expand Down
2 changes: 1 addition & 1 deletion course/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
LANGUAGE_SESSION_KEY,
check_for_language,
)
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from authorization.permissions import ACCESS
from exercise.cache.hierarchy import NoSuchContent
Expand Down
2 changes: 1 addition & 1 deletion deviations/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from exercise.models import BaseExercise
from userprofile.models import UserProfile
Expand Down
2 changes: 1 addition & 1 deletion deviations/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib import messages
from django.db import IntegrityError
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from course.viewbase import CourseInstanceBaseView, CourseInstanceMixin
from lib.viewbase import BaseFormView, BaseRedirectView
Expand Down
2 changes: 1 addition & 1 deletion edit_course/course_forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django_colortag.forms import ColorTagForm

from aplus.api import api_reverse
Expand Down
2 changes: 1 addition & 1 deletion edit_course/exercise_forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from course.models import CourseModule, LearningObjectCategory
from exercise.models import LearningObject, CourseChapter, BaseExercise, \
Expand Down
2 changes: 1 addition & 1 deletion edit_course/managers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from exercise.models import LearningObject, CourseChapter, \
BaseExercise, LTIExercise, StaticExercise, ExerciseWithAttachment
Expand Down
2 changes: 1 addition & 1 deletion edit_course/operations/batch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from exercise.models import BaseExercise, Submission
from lib.helpers import extract_form_errors
Expand Down
2 changes: 1 addition & 1 deletion edit_course/operations/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.core.exceptions import ObjectDoesNotExist
from django.utils import timezone
from django.utils.text import format_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from course.models import Course, CourseInstance, CourseModule, LearningObjectCategory
from exercise.exercisecollection_models import ExerciseCollection
Expand Down
2 changes: 1 addition & 1 deletion edit_course/submission_forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from exercise.forms import SubmissionCreateAndReviewForm
from userprofile.models import UserProfile
Expand Down
6 changes: 3 additions & 3 deletions edit_course/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from django.db import IntegrityError
from django.http.response import Http404, HttpResponse
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy as ungettext
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext_lazy as ngettext
from django.views.generic import ListView, CreateView, UpdateView, DeleteView, \
FormView

Expand Down Expand Up @@ -261,7 +261,7 @@ def form_valid(self, form):
tag_name = tag.name
messages.success(
self.request,
ungettext(
ngettext(
"Tagged user {user_name} with tag {tag_name}.",
"Tagged users {user_name} with tag {tag_name}.",
user_set.count()
Expand Down
2 changes: 1 addition & 1 deletion exercise/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from exercise.models import (
CourseChapter,
Expand Down
2 changes: 1 addition & 1 deletion exercise/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.core.exceptions import PermissionDenied
from django.http.response import HttpResponse
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from wsgiref.util import FileWrapper
from rest_framework import mixins, permissions, viewsets
from rest_framework import status
Expand Down
2 changes: 1 addition & 1 deletion exercise/async_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from lib.email_messages import email_course_error
from lib.helpers import extract_form_errors
Expand Down
2 changes: 1 addition & 1 deletion exercise/exercise_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from django.template import loader
from django.utils import timezone
from django.utils.formats import date_format
from django.utils.translation import get_language, ugettext_lazy as _
from django.utils.translation import get_language, gettext_lazy as _

from aplus.api import api_reverse
from course.models import StudentGroup, CourseInstance, CourseModule, LearningObjectCategory
Expand Down
2 changes: 1 addition & 1 deletion exercise/exercisecollection_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.dispatch import receiver
from django.db.models.signals import post_save
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from django.core.exceptions import ValidationError

Expand Down
2 changes: 1 addition & 1 deletion exercise/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django import forms
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from aplus.api import api_reverse
from exercise.models import Submission
Expand Down
2 changes: 1 addition & 1 deletion exercise/permissions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.http import Http404
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from authorization.permissions import (
ACCESS,
Expand Down
2 changes: 1 addition & 1 deletion exercise/protocol/aplus.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from lib.email_messages import email_course_error
from lib.remote_page import RemotePage, RemotePageException
Expand Down
2 changes: 1 addition & 1 deletion exercise/staff_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.http.response import JsonResponse, Http404
from django.shortcuts import get_object_or_404
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from course.viewbase import CourseInstanceBaseView, CourseInstanceMixin
from course.models import (
Expand Down
2 changes: 1 addition & 1 deletion exercise/submission_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.db import models, DatabaseError
from django.db.models.signals import post_delete
from django.utils import timezone
from django.utils.translation import get_language, ugettext_lazy as _
from django.utils.translation import get_language, gettext_lazy as _
from mimetypes import guess_type

from lib.fields import JSONField, PercentField
Expand Down
2 changes: 1 addition & 1 deletion exercise/templatetags/exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.db.models import Max, Min
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from course.models import CourseModule
from lib.errors import TagUsageError
Expand Down
2 changes: 1 addition & 1 deletion exercise/viewbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from authorization.permissions import ACCESS
from course.viewbase import CourseModuleMixin
Expand Down
2 changes: 1 addition & 1 deletion exercise/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.http.response import Http404, HttpResponse, HttpResponseNotFound
from django.shortcuts import get_object_or_404
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.text import format_lazy
from django.views.decorators.clickjacking import xframe_options_exempt
from django.views.decorators.csrf import csrf_exempt
Expand Down
2 changes: 1 addition & 1 deletion external_services/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db.models.signals import post_save, post_delete
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from lib.cache import CachedAbstract
from .models import MenuItem
Expand Down
2 changes: 1 addition & 1 deletion external_services/lti.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.conf import settings
from django.http import Http404
from django.utils.translation import get_language, ugettext_lazy as _
from django.utils.translation import get_language, gettext_lazy as _
from rest_framework.reverse import reverse
from rest_framework.settings import api_settings
from oauthlib.common import urldecode
Expand Down
2 changes: 1 addition & 1 deletion external_services/permissions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from authorization.permissions import Permission, ObjectVisibleBasePermission
from .models import MenuItem, LTIService
Expand Down
2 changes: 1 addition & 1 deletion external_services/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.core.exceptions import PermissionDenied
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from urllib.parse import urlsplit, parse_qsl

from authorization.permissions import ACCESS
Expand Down
2 changes: 1 addition & 1 deletion lib/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django import forms
from django.core import exceptions
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class PercentField(models.FloatField):
Expand Down
2 changes: 1 addition & 1 deletion lib/remote_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.conf import settings
from django.utils.http import parse_http_date_safe
from django.utils.text import format_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from urllib.parse import urlparse, urljoin


Expand Down
2 changes: 1 addition & 1 deletion lib/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re

from django.core.validators import RegexValidator
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

# The URL key (slug) for a course, course instance, course module, or learning object.
# The key must not consist of only the period (.) since it would be interpreted
Expand Down
2 changes: 1 addition & 1 deletion news/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils import timezone

from course.models import CourseInstance
Expand Down
4 changes: 2 additions & 2 deletions notification/templatetags/notification.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import template
from django.utils.translation import ungettext
from django.utils.translation import ngettext

from ..cache import CachedNotifications

Expand All @@ -20,7 +20,7 @@ def _unread_messages(context):
return {
'count': notifications.count(),
'notifications': notifications.notifications(),
"unread_message": ungettext(
"unread_message": ngettext(
"new notification",
"new notifications",
notifications.count()
Expand Down
2 changes: 1 addition & 1 deletion shibboleth_login/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.http.response import HttpResponse
from django.shortcuts import render, resolve_url
from django.utils.http import is_safe_url
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from .apps import env_settings
from .parser import Parser
Expand Down
2 changes: 1 addition & 1 deletion threshold/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from course.models import (
CourseInstance,
Expand Down
2 changes: 1 addition & 1 deletion userprofile/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
check_for_language,
get_language
)
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext

from lib.helpers import settings_text, remove_query_param_from_url
Expand Down

0 comments on commit b965b76

Please sign in to comment.