From 245b5911e6d872179ae2dd788e5abab703d76127 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Tue, 9 Mar 2021 12:44:05 +0100 Subject: [PATCH] More Django fixes. --- djadmin2/actions.py | 2 +- djadmin2/models.py | 10 +++++----- djadmin2/viewmixins.py | 2 +- docs/internationalization.rst | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/djadmin2/actions.py b/djadmin2/actions.py index b78a8c3..507d19c 100644 --- a/djadmin2/actions.py +++ b/djadmin2/actions.py @@ -2,7 +2,7 @@ from django.contrib import messages from django.db import router from django.utils.encoding import force_str from django.utils.text import capfirst -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.utils.translation import gettext_lazy, ngettext, pgettext_lazy from django.views.generic import TemplateView diff --git a/djadmin2/models.py b/djadmin2/models.py index 2b01c2e..f0595a6 100644 --- a/djadmin2/models.py +++ b/djadmin2/models.py @@ -3,7 +3,7 @@ from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.db import models from django.utils.encoding import force_str -from django.utils.translation import ugettext, gettext_lazy as _ +from django.utils.translation import gettext, gettext_lazy as _ from .utils import quote @@ -46,18 +46,18 @@ class LogEntry(models.Model): def __str__(self): if self.action_flag == self.ADDITION: - return ugettext('Added "%(object)s".') % { + return gettext('Added "%(object)s".') % { 'object': self.object_repr} elif self.action_flag == self.CHANGE: - return ugettext('Changed "%(object)s" - %(changes)s') % { + return gettext('Changed "%(object)s" - %(changes)s') % { 'object': self.object_repr, 'changes': self.change_message, } elif self.action_flag == self.DELETION: - return ugettext('Deleted "%(object)s."') % { + return gettext('Deleted "%(object)s."') % { 'object': self.object_repr} - return ugettext('LogEntry Object') + return gettext('LogEntry Object') def is_addition(self): return self.action_flag == self.ADDITION diff --git a/djadmin2/viewmixins.py b/djadmin2/viewmixins.py index 5a02cd7..f171517 100644 --- a/djadmin2/viewmixins.py +++ b/djadmin2/viewmixins.py @@ -7,7 +7,7 @@ from django.http import HttpResponseRedirect from django.urls import reverse, reverse_lazy from django.utils.encoding import force_str from django.utils.text import get_text_list -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ # braces 1.3 views exported AccessMixin # in braces 1.4 this was moved views._access and not exported in views diff --git a/docs/internationalization.rst b/docs/internationalization.rst index 252132e..9a5da1e 100644 --- a/docs/internationalization.rst +++ b/docs/internationalization.rst @@ -71,7 +71,7 @@ Marking strings for translation **Python code** -Make sure to use ugettext or gettext_lazy on strings that will be shown to the users, +Make sure to use gettext or gettext_lazy on strings that will be shown to the users, with string interpolation ( "%(name_of_variable)s" instead of "%s" ) where needed. Remember that all languages do not use the same word order, so try to provide flexible strings to translate !