Django

Code

Changeset 6582

Show
Ignore:
Timestamp:
10/21/07 12:14:25 (9 months ago)
Author:
mtredinnick
Message:

Fixed #2920 -- Removed _() from builtins.

This is backwards incompatible, but easy to work around.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/conf/__init__.py

    r6300 r6582  
    141141settings = LazySettings() 
    142142 
    143 # This function replaces itself with django.utils.translation.gettext() the 
    144 # first time it's run. This is necessary because the import of 
    145 # django.utils.translation requires a working settings module, and loading it 
    146 # from within this file would cause a circular import. 
    147 def first_time_gettext(*args): 
    148     from django.utils.translation import gettext 
    149     __builtins__['_'] = gettext 
    150     return gettext(*args) 
    151  
    152 __builtins__['_'] = first_time_gettext 
  • django/trunk/django/utils/translation/__init__.py

    r6448 r6582  
    99        'get_language', 'get_language_bidi', 'get_date_formats', 
    1010        'get_partial_date_formats', 'check_for_language', 'to_locale', 
    11         'get_language_from_request', 'install', 'templatize', 'ugettext', 
     11        'get_language_from_request', 'templatize', 'ugettext', 
    1212        'ungettext', 'deactivate_all'] 
    1313 
     
    9797    return real_get_language_from_request(request) 
    9898 
    99 def install(): 
    100     return real_install() 
    101  
    10299def templatize(src): 
    103100    return real_templatize(src) 
  • django/trunk/django/utils/translation/trans_null.py

    r6446 r6582  
    1515 
    1616activate = lambda x: None 
    17 deactivate = deactivate_all = install = lambda: None 
     17deactivate = deactivate_all = lambda: None 
    1818get_language = lambda: settings.LANGUAGE_CODE 
    1919get_language_bidi = lambda: settings.LANGUAGE_CODE in settings.LANGUAGES_BIDI 
  • django/trunk/django/utils/translation/trans_real.py

    r6446 r6582  
    250250def do_translate(message, translation_function): 
    251251    """ 
    252     Translate 'message' using the given 'translation_function' name -- which 
    253     will be either gettext or ugettext. 
     252    Translates 'message' using the given 'translation_function' name -- which 
     253    will be either gettext or ugettext. It uses the current thread to find the 
     254    translation object to use. If no current translation is activated, the 
     255    message will be run through the default translation object. 
    254256    """ 
    255257    global _default, _active 
     
    263265 
    264266def gettext(message): 
    265     """ 
    266     This function will be patched into the builtins module to provide the _ 
    267     helper function. It will use the current thread as a discriminator to find 
    268     the translation object to use. If no current translation is activated, the 
    269     message will be run through the default translation object. 
    270     """ 
    271267    return do_translate(message, 'gettext') 
    272268 
     
    414410        month_day_format = settings.MONTH_DAY_FORMAT 
    415411    return year_month_format, month_day_format 
    416  
    417 def install(): 
    418     """ 
    419     Installs the gettext function as the default translation function under 
    420     the name '_'. 
    421     """ 
    422     __builtins__['_'] = gettext 
    423412 
    424413dot_re = re.compile(r'\S') 
  • django/trunk/tests/regressiontests/templates/tests.py

    r6580 r6582  
    1414from django.template import loader 
    1515from django.template.loaders import app_directories, filesystem 
    16 from django.utils.translation import activate, deactivate, install, ugettext as _ 
     16from django.utils.translation import activate, deactivate, ugettext as _ 
    1717from django.utils.tzinfo import LocalTimezone 
    1818 
     
    845845 
    846846        for name, vals in tests: 
    847             install() 
    848  
    849847            if isinstance(vals[2], tuple): 
    850848                normal_string_result = vals[2][0]