Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

This is backwards incompatible, but easy to work around.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6582 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 7ca708140a723b42d915d98d9f9c633a77460089 1 parent 5f51964
Malcolm Tredinnick authored October 21, 2007
10  django/conf/__init__.py
@@ -140,13 +140,3 @@ def get_all_members(self):
140 140
 
141 141
 settings = LazySettings()
142 142
 
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
5  django/utils/translation/__init__.py
@@ -8,7 +8,7 @@
8 8
         'ngettext_lazy', 'string_concat', 'activate', 'deactivate',
9 9
         'get_language', 'get_language_bidi', 'get_date_formats',
10 10
         'get_partial_date_formats', 'check_for_language', 'to_locale',
11  
-        'get_language_from_request', 'install', 'templatize', 'ugettext',
  11
+        'get_language_from_request', 'templatize', 'ugettext',
12 12
         'ungettext', 'deactivate_all']
13 13
 
14 14
 # Here be dragons, so a short explanation of the logic won't hurt:
@@ -96,9 +96,6 @@ def to_locale(language):
96 96
 def get_language_from_request(request):
97 97
     return real_get_language_from_request(request)
98 98
 
99  
-def install():
100  
-    return real_install()
101  
-
102 99
 def templatize(src):
103 100
     return real_templatize(src)
104 101
 
2  django/utils/translation/trans_null.py
@@ -14,7 +14,7 @@ def ungettext(singular, plural, number):
14 14
     return force_unicode(ngettext(singular, plural, number))
15 15
 
16 16
 activate = lambda x: None
17  
-deactivate = deactivate_all = install = lambda: None
  17
+deactivate = deactivate_all = lambda: None
18 18
 get_language = lambda: settings.LANGUAGE_CODE
19 19
 get_language_bidi = lambda: settings.LANGUAGE_CODE in settings.LANGUAGES_BIDI
20 20
 get_date_formats = lambda: (settings.DATE_FORMAT, settings.DATETIME_FORMAT, settings.TIME_FORMAT)
19  django/utils/translation/trans_real.py
@@ -249,8 +249,10 @@ def catalog():
249 249
 
250 250
 def do_translate(message, translation_function):
251 251
     """
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.
254 256
     """
255 257
     global _default, _active
256 258
     t = _active.get(currentThread(), None)
@@ -262,12 +264,6 @@ def do_translate(message, translation_function):
262 264
     return getattr(_default, translation_function)(message)
263 265
 
264 266
 def 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  
-    """
271 267
     return do_translate(message, 'gettext')
272 268
 
273 269
 def ugettext(message):
@@ -414,13 +410,6 @@ def get_partial_date_formats():
414 410
         month_day_format = settings.MONTH_DAY_FORMAT
415 411
     return year_month_format, month_day_format
416 412
 
417  
-def install():
418  
-    """
419  
-    Installs the gettext function as the default translation function under
420  
-    the name '_'.
421  
-    """
422  
-    __builtins__['_'] = gettext
423  
-
424 413
 dot_re = re.compile(r'\S')
425 414
 def blankout(src, char):
426 415
     """
4  tests/regressiontests/templates/tests.py
@@ -13,7 +13,7 @@
13 13
 from django import template
14 14
 from django.template import loader
15 15
 from django.template.loaders import app_directories, filesystem
16  
-from django.utils.translation import activate, deactivate, install, ugettext as _
  16
+from django.utils.translation import activate, deactivate, ugettext as _
17 17
 from django.utils.tzinfo import LocalTimezone
18 18
 
19 19
 from unicode import unicode_tests
@@ -844,8 +844,6 @@ def test_template_loader(template_name, template_dirs=None):
844 844
         expected_invalid_str = 'INVALID'
845 845
 
846 846
         for name, vals in tests:
847  
-            install()
848  
-
849 847
             if isinstance(vals[2], tuple):
850 848
                 normal_string_result = vals[2][0]
851 849
                 invalid_string_result = vals[2][1]

0 notes on commit 7ca7081

Please sign in to comment.
Something went wrong with that request. Please try again.