Changeset 6582
- Timestamp:
- 10/21/07 12:14:25 (9 months ago)
- Files:
-
- django/trunk/django/conf/__init__.py (modified) (1 diff)
- django/trunk/django/utils/translation/__init__.py (modified) (2 diffs)
- django/trunk/django/utils/translation/trans_null.py (modified) (1 diff)
- django/trunk/django/utils/translation/trans_real.py (modified) (3 diffs)
- django/trunk/tests/regressiontests/templates/tests.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/conf/__init__.py
r6300 r6582 141 141 settings = LazySettings() 142 142 143 # This function replaces itself with django.utils.translation.gettext() the144 # first time it's run. This is necessary because the import of145 # django.utils.translation requires a working settings module, and loading it146 # from within this file would cause a circular import.147 def first_time_gettext(*args):148 from django.utils.translation import gettext149 __builtins__['_'] = gettext150 return gettext(*args)151 152 __builtins__['_'] = first_time_gettextdjango/trunk/django/utils/translation/__init__.py
r6448 r6582 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 … … 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) django/trunk/django/utils/translation/trans_null.py
r6446 r6582 15 15 16 16 activate = lambda x: None 17 deactivate = deactivate_all = install =lambda: None17 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 django/trunk/django/utils/translation/trans_real.py
r6446 r6582 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 … … 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 find268 the translation object to use. If no current translation is activated, the269 message will be run through the default translation object.270 """271 267 return do_translate(message, 'gettext') 272 268 … … 414 410 month_day_format = settings.MONTH_DAY_FORMAT 415 411 return year_month_format, month_day_format 416 417 def install():418 """419 Installs the gettext function as the default translation function under420 the name '_'.421 """422 __builtins__['_'] = gettext423 412 424 413 dot_re = re.compile(r'\S') django/trunk/tests/regressiontests/templates/tests.py
r6580 r6582 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 … … 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]
