Django

Code

Changeset 3247

Show
Ignore:
Timestamp:
06/30/06 22:09:14 (2 years ago)
Author:
adrian
Message:

Added USE_I18N setting, which lets you turn off internationalization overhead with a single setting. Defaults to True. Currently only affects the admin i18n JavaScript?, but I'll be adding other optimizations.

Files:

Legend:

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

    r3226 r3247  
    6868LANGUAGES_BIDI = ("he",) 
    6969 
     70# If you set this to False, Django will make some optimizations so as not 
     71# to load the internationalization machinery. 
     72USE_I18N = True 
     73 
    7074# Not-necessarily-technical managers of the site. They get broken link 
    7175# notifications and other various e-mails. 
  • django/trunk/django/contrib/admin/urls.py

    r3009 r3247  
     1from django.conf import settings 
    12from django.conf.urls.defaults import * 
     3 
     4if settings.USE_I18N: 
     5    i18n_view = 'django.views.i18n.javascript_catalog' 
     6else: 
     7    i18n_view = 'django.views.i18n.null_javascript_catalog' 
    28 
    39urlpatterns = patterns('', 
    410    ('^$', 'django.contrib.admin.views.main.index'), 
    511    ('^r/(\d+)/(.*)/$', 'django.views.defaults.shortcut'), 
    6     ('^jsi18n/$', 'django.views.i18n.javascript_catalog', {'packages': 'django.conf'}), 
     12    ('^jsi18n/$', i18n_view, {'packages': 'django.conf'}), 
    713    ('^logout/$', 'django.contrib.auth.views.logout'), 
    814    ('^password_change/$', 'django.contrib.auth.views.password_change'), 
     
    3036    ('^([^/]+)/([^/]+)/(.+)/$', 'django.contrib.admin.views.main.change_stage'), 
    3137) 
     38 
     39del i18n_view 
  • django/trunk/django/views/i18n.py

    r2809 r3247  
    104104} 
    105105""" 
     106 
     107def null_javascript_catalog(request, domain=None, packages=None): 
     108    """ 
     109    Returns "identity" versions of the JavaScript i18n functions -- i.e., 
     110    versions that don't actually do anything. 
     111    """ 
     112    return http.HttpResponse(NullSource + InterPolate, 'text/javascript') 
    106113 
    107114def javascript_catalog(request, domain='djangojs', packages=None): 
     
    192199    src = ''.join(src) 
    193200    return http.HttpResponse(src, 'text/javascript') 
    194  
  • django/trunk/docs/i18n.txt

    r3125 r3247  
    3636    3. Activate the locale middleware in your Django settings. 
    3737 
    38  
    3938.. admonition:: Behind the scenes 
    4039 
    4140    Django's translation machinery uses the standard ``gettext`` module that 
    4241    comes with Python. 
     42 
     43If you don't need internationalization 
     44====================================== 
     45 
     46Django's internationalization hooks are on by default, and that means there's a 
     47bit of i18n-related overhead in certain places of the framework. If you don't 
     48use internationalization, you should take the two seconds to set 
     49``USE_I18N = False`` in your settings file. If ``USE_I18N`` is set to 
     50``False``, then Django will make some optimizations so as not to load the 
     51internationalization machinery. 
     52 
     53See the `documentation for USE_I18N`_. 
     54 
     55.. _documentation for USE_I18N: http://www.djangoproject.com/documentation/settings/#use-i18n 
    4356 
    4457How to specify translation strings 
  • django/trunk/docs/settings.txt

    r3055 r3247  
    739739is installed (see the `middleware docs`_). 
    740740 
     741USE_I18N 
     742-------- 
     743 
     744Default: ``True`` 
     745 
     746A boolean that specifies whether Django's internationalization system should be 
     747enabled. This provides an easy way to turn it off, for performance. If this is 
     748set to ``False, Django will make some optimizations so as not to load the 
     749internationalization machinery. 
     750 
    741751YEAR_MONTH_FORMAT 
    742752-----------------