Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@malcolmt malcolmt authored
View
10 django/conf/__init__.py
@@ -140,13 +140,3 @@ def get_all_members(self):
settings = LazySettings()
-# This function replaces itself with django.utils.translation.gettext() the
-# first time it's run. This is necessary because the import of
-# django.utils.translation requires a working settings module, and loading it
-# from within this file would cause a circular import.
-def first_time_gettext(*args):
- from django.utils.translation import gettext
- __builtins__['_'] = gettext
- return gettext(*args)
-
-__builtins__['_'] = first_time_gettext
View
5 django/utils/translation/__init__.py
@@ -8,7 +8,7 @@
'ngettext_lazy', 'string_concat', 'activate', 'deactivate',
'get_language', 'get_language_bidi', 'get_date_formats',
'get_partial_date_formats', 'check_for_language', 'to_locale',
- 'get_language_from_request', 'install', 'templatize', 'ugettext',
+ 'get_language_from_request', 'templatize', 'ugettext',
'ungettext', 'deactivate_all']
# Here be dragons, so a short explanation of the logic won't hurt:
@@ -96,9 +96,6 @@ def to_locale(language):
def get_language_from_request(request):
return real_get_language_from_request(request)
-def install():
- return real_install()
-
def templatize(src):
return real_templatize(src)
View
2  django/utils/translation/trans_null.py
@@ -14,7 +14,7 @@ def ungettext(singular, plural, number):
return force_unicode(ngettext(singular, plural, number))
activate = lambda x: None
-deactivate = deactivate_all = install = lambda: None
+deactivate = deactivate_all = lambda: None
get_language = lambda: settings.LANGUAGE_CODE
get_language_bidi = lambda: settings.LANGUAGE_CODE in settings.LANGUAGES_BIDI
get_date_formats = lambda: (settings.DATE_FORMAT, settings.DATETIME_FORMAT, settings.TIME_FORMAT)
View
19 django/utils/translation/trans_real.py
@@ -249,8 +249,10 @@ def catalog():
def do_translate(message, translation_function):
"""
- Translate 'message' using the given 'translation_function' name -- which
- will be either gettext or ugettext.
+ Translates 'message' using the given 'translation_function' name -- which
+ will be either gettext or ugettext. It uses the current thread to find the
+ translation object to use. If no current translation is activated, the
+ message will be run through the default translation object.
"""
global _default, _active
t = _active.get(currentThread(), None)
@@ -262,12 +264,6 @@ def do_translate(message, translation_function):
return getattr(_default, translation_function)(message)
def gettext(message):
- """
- This function will be patched into the builtins module to provide the _
- helper function. It will use the current thread as a discriminator to find
- the translation object to use. If no current translation is activated, the
- message will be run through the default translation object.
- """
return do_translate(message, 'gettext')
def ugettext(message):
@@ -414,13 +410,6 @@ def get_partial_date_formats():
month_day_format = settings.MONTH_DAY_FORMAT
return year_month_format, month_day_format
-def install():
- """
- Installs the gettext function as the default translation function under
- the name '_'.
- """
- __builtins__['_'] = gettext
-
dot_re = re.compile(r'\S')
def blankout(src, char):
"""
View
4 tests/regressiontests/templates/tests.py
@@ -13,7 +13,7 @@
from django import template
from django.template import loader
from django.template.loaders import app_directories, filesystem
-from django.utils.translation import activate, deactivate, install, ugettext as _
+from django.utils.translation import activate, deactivate, ugettext as _
from django.utils.tzinfo import LocalTimezone
from unicode import unicode_tests
@@ -844,8 +844,6 @@ def test_template_loader(template_name, template_dirs=None):
expected_invalid_str = 'INVALID'
for name, vals in tests:
- install()
-
if isinstance(vals[2], tuple):
normal_string_result = vals[2][0]
invalid_string_result = vals[2][1]

0 comments on commit 7ca7081

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