Django

Code

Changeset 4485

Show
Ignore:
Timestamp:
02/11/07 00:20:52 (2 years ago)
Author:
russellm
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/admin/filterspecs.py

    r4265 r4485  
    88 
    99from django.db import models 
     10from django.utils.translation import gettext as _ 
    1011import datetime 
    1112 
  • django/trunk/django/contrib/admin/templatetags/admin_list.py

    r4309 r4485  
    77from django.utils.html import escape 
    88from django.utils.text import capfirst 
    9 from django.utils.translation import get_date_formats, get_partial_date_formats 
     9from django.utils.translation import get_date_formats, get_partial_date_formats, gettext as _ 
    1010from django.template import Library 
    1111import datetime 
  • django/trunk/django/contrib/admin/views/auth.py

    r4266 r4485  
    77from django.http import HttpResponseRedirect 
    88from django.utils.html import escape 
     9from django.utils.translation import gettext as _ 
    910 
    1011def user_add_stage(request): 
  • django/trunk/django/contrib/admin/views/decorators.py

    r4265 r4485  
    44from django.contrib.auth import authenticate, login 
    55from django.shortcuts import render_to_response 
    6 from django.utils.translation import gettext_lazy 
     6from django.utils.translation import gettext_lazy, gettext as _ 
    77import base64, datetime, md5 
    88import cPickle as pickle 
  • django/trunk/django/contrib/admin/views/doc.py

    r4265 r4485  
    1010from django.contrib.admin import utils 
    1111from django.contrib.sites.models import Site 
     12from django.utils.translation import gettext as _ 
    1213import inspect, os, re 
    1314 
  • django/trunk/django/contrib/admin/views/main.py

    r4269 r4485  
    1313from django.utils.html import escape 
    1414from django.utils.text import capfirst, get_text_list 
     15from django.utils.translation import gettext as _ 
    1516import operator 
    1617 
  • django/trunk/django/contrib/auth/views.py

    r4208 r4485  
    88from django.contrib.auth.decorators import login_required 
    99from django.contrib.auth import LOGIN_URL, REDIRECT_FIELD_NAME 
     10from django.utils.translation import gettext as _ 
    1011 
    1112def login(request, template_name='registration/login.html'): 
  • django/trunk/django/contrib/comments/views/comments.py

    r4208 r4485  
    1212from django.utils.text import normalize_newlines 
    1313from django.conf import settings 
    14 from django.utils.translation import ngettext 
     14from django.utils.translation import ngettext, gettext as _ 
    1515import base64, datetime 
    1616 
  • django/trunk/django/contrib/comments/views/karma.py

    r3360 r4485  
    33from django.template import RequestContext 
    44from django.contrib.comments.models import Comment, KarmaScore 
     5from django.utils.translation import gettext as _ 
    56 
    67def vote(request, comment_id, vote): 
  • django/trunk/django/core/cache/__init__.py

    r4265 r4485  
    1919from django.conf import settings 
    2020from django.core.cache.backends.base import InvalidCacheBackendError 
     21from django.utils.translation import gettext as _ 
    2122 
    2223BACKENDS = { 
  • django/trunk/django/core/validators.py

    r4039 r4485  
    236236        u = urllib2.urlopen(req) 
    237237    except ValueError: 
    238         raise ValidationError, _("Invalid URL: %s") % field_data 
     238        raise ValidationError, gettext("Invalid URL: %s") % field_data 
    239239    except urllib2.HTTPError, e: 
    240240        # 401s are valid; they just mean authorization is required. 
    241241        # 301 and 302 are redirects; they just mean look somewhere else. 
    242242        if str(e.code) not in ('401','301','302'): 
    243             raise ValidationError, _("The URL %s is a broken link.") % field_data 
     243            raise ValidationError, gettext("The URL %s is a broken link.") % field_data 
    244244    except: # urllib2.URLError, httplib.InvalidURL, etc. 
    245         raise ValidationError, _("The URL %s is a broken link.") % field_data 
     245        raise ValidationError, gettext("The URL %s is a broken link.") % field_data 
    246246         
    247247def isValidUSState(field_data, all_data): 
     
    538538            m = re.search(r'Expected "(.*?)" to terminate element starting on line (\d+)', message) 
    539539            if m: 
    540                 display_errors.append(_('Please close the unclosed %(tag)s tag from line %(line)s. (Line starts with "%(start)s".)') % \ 
     540                display_errors.append(gettext('Please close the unclosed %(tag)s tag from line %(line)s. (Line starts with "%(start)s".)') % \ 
    541541                    {'tag':m.group(1).replace('/', ''), 'line':m.group(2), 'start':lines[int(m.group(2)) - 1][:30]}) 
    542542                continue 
    543543            if message.strip() == 'text not allowed here': 
    544                 display_errors.append(_('Some text starting on line %(line)s is not allowed in that context. (Line starts with "%(start)s".)') % \ 
     544                display_errors.append(gettext('Some text starting on line %(line)s is not allowed in that context. (Line starts with "%(start)s".)') % \ 
    545545                    {'line':line, 'start':lines[int(line) - 1][:30]}) 
    546546                continue 
    547547            m = re.search(r'\s*attribute "(.*?)" not allowed at this point; ignored', message) 
    548548            if m: 
    549                 display_errors.append(_('"%(attr)s" on line %(line)s is an invalid attribute. (Line starts with "%(start)s".)') % \ 
     549                display_errors.append(gettext('"%(attr)s" on line %(line)s is an invalid attribute. (Line starts with "%(start)s".)') % \ 
    550550                    {'attr':m.group(1), 'line':line, 'start':lines[int(line) - 1][:30]}) 
    551551                continue 
    552552            m = re.search(r'\s*unknown element "(.*?)"', message) 
    553553            if m: 
    554                 display_errors.append(_('"<%(tag)s>" on line %(line)s is an invalid tag. (Line starts with "%(start)s".)') % \ 
     554                display_errors.append(gettext('"<%(tag)s>" on line %(line)s is an invalid tag. (Line starts with "%(start)s".)') % \ 
    555555                    {'tag':m.group(1), 'line':line, 'start':lines[int(line) - 1][:30]}) 
    556556                continue 
    557557            if message.strip() == 'required attributes missing': 
    558                 display_errors.append(_('A tag on line %(line)s is missing one or more required attributes. (Line starts with "%(start)s".)') % \ 
     558                display_errors.append(gettext('A tag on line %(line)s is missing one or more required attributes. (Line starts with "%(start)s".)') % \ 
    559559                    {'line':line, 'start':lines[int(line) - 1][:30]}) 
    560560                continue 
    561561            m = re.search(r'\s*bad value for attribute "(.*?)"', message) 
    562562            if m: 
    563                 display_errors.append(_('The "%(attr)s" attribute on line %(line)s has an invalid value. (Line starts with "%(start)s".)') % \ 
     563                display_errors.append(gettext('The "%(attr)s" attribute on line %(line)s has an invalid value. (Line starts with "%(start)s".)') % \ 
    564564                    {'attr':m.group(1), 'line':line, 'start':lines[int(line) - 1][:30]}) 
    565565                continue 
  • django/trunk/django/db/__init__.py

    r4265 r4485  
    22from django.core import signals 
    33from django.dispatch import dispatcher 
     4from django.utils.translation import gettext as _ 
    45 
    56__all__ = ('backend', 'connection', 'DatabaseError') 
  • django/trunk/django/db/models/fields/__init__.py

    r4442 r4485  
    617617            f = os.path.abspath(os.path.join(settings.MEDIA_ROOT, field_data)) 
    618618            if not f.startswith(os.path.abspath(os.path.normpath(settings.MEDIA_ROOT))): 
    619                 raise validators.ValidationError, _("Enter a valid filename.") 
     619                raise validators.ValidationError, gettext("Enter a valid filename.") 
    620620        field_list[1].validator_list.append(isWithinMediaRoot) 
    621621        return field_list 
  • django/trunk/django/db/models/fields/related.py

    r4448 r4485  
    44from django.db.models.related import RelatedObject 
    55from django.utils.text import capfirst 
    6 from django.utils.translation import gettext_lazy, string_concat, ngettext 
     6from django.utils.translation import gettext_lazy, string_concat, ngettext, gettext 
    77from django.utils.functional import curry 
    88from django.core import validators 
     
    5151        klass._default_manager.get(**{f.rel.field_name: field_data}) 
    5252    except klass.DoesNotExist: 
    53         raise validators.ValidationError, _("Please enter a valid %s.") % f.verbose_name 
     53        raise validators.ValidationError, gettext("Please enter a valid %s.") % f.verbose_name 
    5454 
    5555#HACK 
  • django/trunk/django/db/models/manipulators.py

    r4265 r4485  
    88from django.utils.datastructures import DotExpandedDict 
    99from django.utils.text import capfirst 
     10from django.utils.translation import gettext as _ 
    1011import types 
    1112 
  • django/trunk/django/http/__init__.py

    r4472 r4485  
    44from urllib import urlencode, quote 
    55from django.utils.datastructures import MultiValueDict 
     6from django.utils.translation import gettext as _ 
    67 
    78RESERVED_CHARS="!*'();:@&=+$,/?%#[]" 
  • django/trunk/django/oldforms/__init__.py

    r4422 r4485  
    570570    def __init__(self, field_name, is_required=False, validator_list=None): 
    571571        if validator_list is None: validator_list = [] 
    572         SelectField.__init__(self, field_name, choices=[('1', _('Unknown')), ('2', _('Yes')), ('3', _('No'))], 
     572        SelectField.__init__(self, field_name, choices=[('1', gettext('Unknown')), ('2', gettext('Yes')), ('3', gettext('No'))], 
    573573            is_required=is_required, validator_list=validator_list) 
    574574 
  • django/trunk/django/test/simple.py

    r4265 r4485  
    44from django.test.utils import setup_test_environment, teardown_test_environment 
    55from django.test.utils import create_test_db, destroy_test_db 
     6from django.utils.translation import gettext as _ 
    67from django.test.testcases import OutputChecker, DocTestRunner 
    78 
  • django/trunk/django/utils/translation/trans_real.py

    r4265 r4485  
    360360    """ 
    361361    from django.conf import settings 
    362     date_format = _('DATE_FORMAT') 
    363     datetime_format = _('DATETIME_FORMAT') 
    364     time_format = _('TIME_FORMAT') 
     362    date_format = gettext('DATE_FORMAT') 
     363    datetime_format = gettext('DATETIME_FORMAT') 
     364    time_format = gettext('TIME_FORMAT') 
    365365    if date_format == 'DATE_FORMAT': 
    366366        date_format = settings.DATE_FORMAT 
     
    378378    """ 
    379379    from django.conf import settings 
    380     year_month_format = _('YEAR_MONTH_FORMAT') 
    381     month_day_format = _('MONTH_DAY_FORMAT') 
     380    year_month_format = gettext('YEAR_MONTH_FORMAT') 
     381    month_day_format = gettext('MONTH_DAY_FORMAT') 
    382382    if year_month_format == 'YEAR_MONTH_FORMAT': 
    383383        year_month_format = settings.YEAR_MONTH_FORMAT 
  • django/trunk/tests/regressiontests/defaultfilters/tests.py

    r4468 r4485  
    392392 
    393393from django.template.defaultfilters import * 
     394from django.utils.translation import gettext as _ 
    394395import datetime 
    395396