summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2007-02-11 06:20:52 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2007-02-11 06:20:52 +0000
commit0e924c70b1ec5cae635a99d9fe7e279698dc5cd0 (patch)
tree6f3b70da88f2c1fdbc191bf6a476a42e8d4f485c
parentb767b5831d4bdd1cff04474278ea43e24c20274c (diff)
Refs #2920 -- Replaced implicit uses of _() with explicit imports or calls to gettext(). At some point post 0.96, we need to remove the calls that put _ into the builtins.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4485 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/admin/filterspecs.py1
-rw-r--r--django/contrib/admin/templatetags/admin_list.py2
-rw-r--r--django/contrib/admin/views/auth.py1
-rw-r--r--django/contrib/admin/views/decorators.py2
-rw-r--r--django/contrib/admin/views/doc.py1
-rw-r--r--django/contrib/admin/views/main.py1
-rw-r--r--django/contrib/auth/views.py1
-rw-r--r--django/contrib/comments/views/comments.py2
-rw-r--r--django/contrib/comments/views/karma.py1
-rw-r--r--django/core/cache/__init__.py1
-rw-r--r--django/core/validators.py18
-rw-r--r--django/db/__init__.py1
-rw-r--r--django/db/models/fields/__init__.py2
-rw-r--r--django/db/models/fields/related.py4
-rw-r--r--django/db/models/manipulators.py1
-rw-r--r--django/http/__init__.py1
-rw-r--r--django/oldforms/__init__.py2
-rw-r--r--django/test/simple.py1
-rw-r--r--django/utils/translation/trans_real.py10
-rw-r--r--tests/regressiontests/defaultfilters/tests.py1
20 files changed, 33 insertions, 21 deletions
diff --git a/django/contrib/admin/filterspecs.py b/django/contrib/admin/filterspecs.py
index 8c2b82147e..8d0f60f0ad 100644
--- a/django/contrib/admin/filterspecs.py
+++ b/django/contrib/admin/filterspecs.py
@@ -7,6 +7,7 @@ certain test -- e.g. being a DateField or ForeignKey.
"""
from django.db import models
+from django.utils.translation import gettext as _
import datetime
class FilterSpec(object):
diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
index 3c0c6f0ac2..6041c3208d 100644
--- a/django/contrib/admin/templatetags/admin_list.py
+++ b/django/contrib/admin/templatetags/admin_list.py
@@ -6,7 +6,7 @@ from django.db import models
from django.utils import dateformat
from django.utils.html import escape
from django.utils.text import capfirst
-from django.utils.translation import get_date_formats, get_partial_date_formats
+from django.utils.translation import get_date_formats, get_partial_date_formats, gettext as _
from django.template import Library
import datetime
diff --git a/django/contrib/admin/views/auth.py b/django/contrib/admin/views/auth.py
index bea1f8533c..df5990b74f 100644
--- a/django/contrib/admin/views/auth.py
+++ b/django/contrib/admin/views/auth.py
@@ -6,6 +6,7 @@ from django import oldforms, template
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponseRedirect
from django.utils.html import escape
+from django.utils.translation import gettext as _
def user_add_stage(request):
if not request.user.has_perm('auth.change_user'):
diff --git a/django/contrib/admin/views/decorators.py b/django/contrib/admin/views/decorators.py
index 9dfe651fe6..d259948ea9 100644
--- a/django/contrib/admin/views/decorators.py
+++ b/django/contrib/admin/views/decorators.py
@@ -3,7 +3,7 @@ from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth import authenticate, login
from django.shortcuts import render_to_response
-from django.utils.translation import gettext_lazy
+from django.utils.translation import gettext_lazy, gettext as _
import base64, datetime, md5
import cPickle as pickle
diff --git a/django/contrib/admin/views/doc.py b/django/contrib/admin/views/doc.py
index 4b592acebd..fdc99f2923 100644
--- a/django/contrib/admin/views/doc.py
+++ b/django/contrib/admin/views/doc.py
@@ -9,6 +9,7 @@ from django.http import Http404, get_host
from django.core import urlresolvers
from django.contrib.admin import utils
from django.contrib.sites.models import Site
+from django.utils.translation import gettext as _
import inspect, os, re
# Exclude methods starting with these strings from documentation
diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
index 282038e205..1cca8c657f 100644
--- a/django/contrib/admin/views/main.py
+++ b/django/contrib/admin/views/main.py
@@ -12,6 +12,7 @@ from django.db.models.query import handle_legacy_orderlist, QuerySet
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.utils.html import escape
from django.utils.text import capfirst, get_text_list
+from django.utils.translation import gettext as _
import operator
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE, DELETION
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index fda17b91fb..be3eac2075 100644
--- a/django/contrib/auth/views.py
+++ b/django/contrib/auth/views.py
@@ -7,6 +7,7 @@ from django.contrib.sites.models import Site
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.contrib.auth import LOGIN_URL, REDIRECT_FIELD_NAME
+from django.utils.translation import gettext as _
def login(request, template_name='registration/login.html'):
"Displays the login form and handles the login action."
diff --git a/django/contrib/comments/views/comments.py b/django/contrib/comments/views/comments.py
index 12330afe41..bc156b31b3 100644
--- a/django/contrib/comments/views/comments.py
+++ b/django/contrib/comments/views/comments.py
@@ -11,7 +11,7 @@ from django.contrib.auth.forms import AuthenticationForm
from django.http import HttpResponseRedirect
from django.utils.text import normalize_newlines
from django.conf import settings
-from django.utils.translation import ngettext
+from django.utils.translation import ngettext, gettext as _
import base64, datetime
COMMENTS_PER_PAGE = 20
diff --git a/django/contrib/comments/views/karma.py b/django/contrib/comments/views/karma.py
index 8c18523feb..de8c6f44a3 100644
--- a/django/contrib/comments/views/karma.py
+++ b/django/contrib/comments/views/karma.py
@@ -2,6 +2,7 @@ from django.http import Http404
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.comments.models import Comment, KarmaScore
+from django.utils.translation import gettext as _
def vote(request, comment_id, vote):
"""
diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py
index 6da8e883b9..4195e97da4 100644
--- a/django/core/cache/__init__.py
+++ b/django/core/cache/__init__.py
@@ -18,6 +18,7 @@ See docs/cache.txt for information on the public API.
from cgi import parse_qsl
from django.conf import settings
from django.core.cache.backends.base import InvalidCacheBackendError
+from django.utils.translation import gettext as _
BACKENDS = {
# name for use in settings file --> name of module in "backends" directory
diff --git a/django/core/validators.py b/django/core/validators.py
index a2f3dc3bc3..c937e7bff3 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -235,14 +235,14 @@ def isExistingURL(field_data, all_data):
req = urllib2.Request(field_data,None, headers)
u = urllib2.urlopen(req)
except ValueError:
- raise ValidationError, _("Invalid URL: %s") % field_data
+ raise ValidationError, gettext("Invalid URL: %s") % field_data
except urllib2.HTTPError, e:
# 401s are valid; they just mean authorization is required.
# 301 and 302 are redirects; they just mean look somewhere else.
if str(e.code) not in ('401','301','302'):
- raise ValidationError, _("The URL %s is a broken link.") % field_data
+ raise ValidationError, gettext("The URL %s is a broken link.") % field_data
except: # urllib2.URLError, httplib.InvalidURL, etc.
- raise ValidationError, _("The URL %s is a broken link.") % field_data
+ raise ValidationError, gettext("The URL %s is a broken link.") % field_data
def isValidUSState(field_data, all_data):
"Checks that the given string is a valid two-letter U.S. state abbreviation"
@@ -537,30 +537,30 @@ class RelaxNGCompact(object):
# Scrape the Jing error messages to reword them more nicely.
m = re.search(r'Expected "(.*?)" to terminate element starting on line (\d+)', message)
if m:
- display_errors.append(_('Please close the unclosed %(tag)s tag from line %(line)s. (Line starts with "%(start)s".)') % \
+ display_errors.append(gettext('Please close the unclosed %(tag)s tag from line %(line)s. (Line starts with "%(start)s".)') % \
{'tag':m.group(1).replace('/', ''), 'line':m.group(2), 'start':lines[int(m.group(2)) - 1][:30]})
continue
if message.strip() == 'text not allowed here':
- display_errors.append(_('Some text starting on line %(line)s is not allowed in that context. (Line starts with "%(start)s".)') % \
+ display_errors.append(gettext('Some text starting on line %(line)s is not allowed in that context. (Line starts with "%(start)s".)') % \
{'line':line, 'start':lines[int(line) - 1][:30]})
continue
m = re.search(r'\s*attribute "(.*?)" not allowed at this point; ignored', message)
if m:
- display_errors.append(_('"%(attr)s" on line %(line)s is an invalid attribute. (Line starts with "%(start)s".)') % \
+ display_errors.append(gettext('"%(attr)s" on line %(line)s is an invalid attribute. (Line starts with "%(start)s".)') % \
{'attr':m.group(1), 'line':line, 'start':lines[int(line) - 1][:30]})
continue
m = re.search(r'\s*unknown element "(.*?)"', message)
if m:
- display_errors.append(_('"<%(tag)s>" on line %(line)s is an invalid tag. (Line starts with "%(start)s".)') % \
+ display_errors.append(gettext('"<%(tag)s>" on line %(line)s is an invalid tag. (Line starts with "%(start)s".)') % \
{'tag':m.group(1), 'line':line, 'start':lines[int(line) - 1][:30]})
continue
if message.strip() == 'required attributes missing':
- display_errors.append(_('A tag on line %(line)s is missing one or more required attributes. (Line starts with "%(start)s".)') % \
+ display_errors.append(gettext('A tag on line %(line)s is missing one or more required attributes. (Line starts with "%(start)s".)') % \
{'line':line, 'start':lines[int(line) - 1][:30]})
continue
m = re.search(r'\s*bad value for attribute "(.*?)"', message)
if m:
- display_errors.append(_('The "%(attr)s" attribute on line %(line)s has an invalid value. (Line starts with "%(start)s".)') % \
+ display_errors.append(gettext('The "%(attr)s" attribute on line %(line)s has an invalid value. (Line starts with "%(start)s".)') % \
{'attr':m.group(1), 'line':line, 'start':lines[int(line) - 1][:30]})
continue
# Failing all those checks, use the default error message.
diff --git a/django/db/__init__.py b/django/db/__init__.py
index 4176b5aa79..14d42b39c9 100644
--- a/django/db/__init__.py
+++ b/django/db/__init__.py
@@ -1,6 +1,7 @@
from django.conf import settings
from django.core import signals
from django.dispatch import dispatcher
+from django.utils.translation import gettext as _
__all__ = ('backend', 'connection', 'DatabaseError')
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 024fa95b8e..8a1e499bd5 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -616,7 +616,7 @@ class FileField(Field):
def isWithinMediaRoot(field_data, all_data):
f = os.path.abspath(os.path.join(settings.MEDIA_ROOT, field_data))
if not f.startswith(os.path.abspath(os.path.normpath(settings.MEDIA_ROOT))):
- raise validators.ValidationError, _("Enter a valid filename.")
+ raise validators.ValidationError, gettext("Enter a valid filename.")
field_list[1].validator_list.append(isWithinMediaRoot)
return field_list
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index b517747735..35983203de 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -3,7 +3,7 @@ from django.db.models import signals, get_model
from django.db.models.fields import AutoField, Field, IntegerField, get_ul_class
from django.db.models.related import RelatedObject
from django.utils.text import capfirst
-from django.utils.translation import gettext_lazy, string_concat, ngettext
+from django.utils.translation import gettext_lazy, string_concat, ngettext, gettext
from django.utils.functional import curry
from django.core import validators
from django import oldforms
@@ -50,7 +50,7 @@ def manipulator_valid_rel_key(f, self, field_data, all_data):
try:
klass._default_manager.get(**{f.rel.field_name: field_data})
except klass.DoesNotExist:
- raise validators.ValidationError, _("Please enter a valid %s.") % f.verbose_name
+ raise validators.ValidationError, gettext("Please enter a valid %s.") % f.verbose_name
#HACK
class RelatedField(object):
diff --git a/django/db/models/manipulators.py b/django/db/models/manipulators.py
index aea3aa70a7..ad73091461 100644
--- a/django/db/models/manipulators.py
+++ b/django/db/models/manipulators.py
@@ -7,6 +7,7 @@ from django.db.models import signals
from django.utils.functional import curry
from django.utils.datastructures import DotExpandedDict
from django.utils.text import capfirst
+from django.utils.translation import gettext as _
import types
def add_manipulators(sender):
diff --git a/django/http/__init__.py b/django/http/__init__.py
index a6538b7d4a..3a4acd1a36 100644
--- a/django/http/__init__.py
+++ b/django/http/__init__.py
@@ -3,6 +3,7 @@ from Cookie import SimpleCookie
from pprint import pformat
from urllib import urlencode, quote
from django.utils.datastructures import MultiValueDict
+from django.utils.translation import gettext as _
RESERVED_CHARS="!*'();:@&=+$,/?%#[]"
diff --git a/django/oldforms/__init__.py b/django/oldforms/__init__.py
index decf0f7064..e78baf7113 100644
--- a/django/oldforms/__init__.py
+++ b/django/oldforms/__init__.py
@@ -569,7 +569,7 @@ class NullBooleanField(SelectField):
"This SelectField provides 'Yes', 'No' and 'Unknown', mapping results to True, False or None"
def __init__(self, field_name, is_required=False, validator_list=None):
if validator_list is None: validator_list = []
- SelectField.__init__(self, field_name, choices=[('1', _('Unknown')), ('2', _('Yes')), ('3', _('No'))],
+ SelectField.__init__(self, field_name, choices=[('1', gettext('Unknown')), ('2', gettext('Yes')), ('3', gettext('No'))],
is_required=is_required, validator_list=validator_list)
def render(self, data):
diff --git a/django/test/simple.py b/django/test/simple.py
index 88e6b49925..9d0bac4641 100644
--- a/django/test/simple.py
+++ b/django/test/simple.py
@@ -3,6 +3,7 @@ from django.conf import settings
from django.core import management
from django.test.utils import setup_test_environment, teardown_test_environment
from django.test.utils import create_test_db, destroy_test_db
+from django.utils.translation import gettext as _
from django.test.testcases import OutputChecker, DocTestRunner
# The module name for tests outside models.py
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index 94df23a8e9..899d58a8ce 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -359,9 +359,9 @@ def get_date_formats():
one, the formats provided in the settings will be used.
"""
from django.conf import settings
- date_format = _('DATE_FORMAT')
- datetime_format = _('DATETIME_FORMAT')
- time_format = _('TIME_FORMAT')
+ date_format = gettext('DATE_FORMAT')
+ datetime_format = gettext('DATETIME_FORMAT')
+ time_format = gettext('TIME_FORMAT')
if date_format == 'DATE_FORMAT':
date_format = settings.DATE_FORMAT
if datetime_format == 'DATETIME_FORMAT':
@@ -377,8 +377,8 @@ def get_partial_date_formats():
one, the formats provided in the settings will be used.
"""
from django.conf import settings
- year_month_format = _('YEAR_MONTH_FORMAT')
- month_day_format = _('MONTH_DAY_FORMAT')
+ year_month_format = gettext('YEAR_MONTH_FORMAT')
+ month_day_format = gettext('MONTH_DAY_FORMAT')
if year_month_format == 'YEAR_MONTH_FORMAT':
year_month_format = settings.YEAR_MONTH_FORMAT
if month_day_format == 'MONTH_DAY_FORMAT':
diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py
index 481557b782..ec5d26aba1 100644
--- a/tests/regressiontests/defaultfilters/tests.py
+++ b/tests/regressiontests/defaultfilters/tests.py
@@ -391,6 +391,7 @@ False
"""
from django.template.defaultfilters import *
+from django.utils.translation import gettext as _
import datetime
if __name__ == '__main__':