mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	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
This commit is contained in:
		| @@ -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): | ||||
|   | ||||
| @@ -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 | ||||
|  | ||||
|   | ||||
| @@ -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'): | ||||
|   | ||||
| @@ -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 | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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." | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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): | ||||
|     """ | ||||
|   | ||||
							
								
								
									
										1
									
								
								django/core/cache/__init__.py
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								django/core/cache/__init__.py
									
									
									
									
										vendored
									
									
								
							| @@ -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 | ||||
|   | ||||
| @@ -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. | ||||
|   | ||||
| @@ -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') | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|  | ||||
|   | ||||
| @@ -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): | ||||
|   | ||||
| @@ -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): | ||||
|   | ||||
| @@ -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="!*'();:@&=+$,/?%#[]" | ||||
|  | ||||
|   | ||||
| @@ -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): | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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': | ||||
|   | ||||
| @@ -391,6 +391,7 @@ False | ||||
| """ | ||||
|  | ||||
| from django.template.defaultfilters import * | ||||
| from django.utils.translation import gettext as _ | ||||
| import datetime | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|   | ||||
		Reference in New Issue
	
	Block a user