diff --git a/django/conf/__init__.py b/django/conf/__init__.py index f19e509ea3..0177490df9 100644 --- a/django/conf/__init__.py +++ b/django/conf/__init__.py @@ -140,13 +140,3 @@ class UserSettingsHolder(object): 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 diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py index 9ca7419e1e..43ce3e591a 100644 --- a/django/utils/translation/__init__.py +++ b/django/utils/translation/__init__.py @@ -8,7 +8,7 @@ __all__ = ['gettext', 'gettext_noop', 'gettext_lazy', 'ngettext', '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) diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py index 771a80e99c..0b62907e44 100644 --- a/django/utils/translation/trans_null.py +++ b/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) diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 250af04e8c..3427d721bf 100644 --- a/django/utils/translation/trans_real.py +++ b/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): """ diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index b0d4957fbb..60f7d54145 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -13,7 +13,7 @@ from datetime import datetime, timedelta 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 @@ class Templates(unittest.TestCase): 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]