diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py
index 13fc8a8..a831c83 100644
|
a
|
b
|
|
| 2 | 2 | Internationalization support. |
| 3 | 3 | """ |
| 4 | 4 | from django.utils.functional import lazy |
| | 5 | import traceback |
| | 6 | import threading |
| 5 | 7 | |
| 6 | 8 | __all__ = ['gettext', 'gettext_noop', 'gettext_lazy', 'ngettext', |
| 7 | 9 | 'ngettext_lazy', 'string_concat', 'activate', 'deactivate', |
| … |
… |
__all__ = ['gettext', 'gettext_noop', 'gettext_lazy', 'ngettext',
|
| 18 | 20 | # replace the functions with their real counterparts (once we do access the |
| 19 | 21 | # settings). |
| 20 | 22 | |
| | 23 | _init_lock = threading.Lock() |
| | 24 | _initialised = False |
| | 25 | |
| 21 | 26 | def delayed_loader(*args, **kwargs): |
| 22 | 27 | """ |
| 23 | 28 | Replace each real_* function with the corresponding function from either |
| … |
… |
def delayed_loader(*args, **kwargs):
|
| 26 | 31 | first time any i18n method is called. It replaces all the i18n methods at |
| 27 | 32 | once at that time. |
| 28 | 33 | """ |
| 29 | | import traceback |
| 30 | | from django.conf import settings |
| 31 | | if settings.USE_I18N: |
| 32 | | import trans_real as trans |
| 33 | | else: |
| 34 | | import trans_null as trans |
| 35 | | caller = traceback.extract_stack(limit=2)[0][2] |
| 36 | | g = globals() |
| 37 | | for name in __all__: |
| 38 | | if hasattr(trans, name): |
| 39 | | g['real_%s' % name] = getattr(trans, name) |
| 40 | | |
| 41 | | # Make the originally requested function call on the way out the door. |
| 42 | | return g[caller](*args, **kwargs) |
| | 34 | global _initialised |
| | 35 | _init_lock.acquire() |
| | 36 | try: |
| | 37 | caller = traceback.extract_stack(limit=2)[0][2] |
| | 38 | g = globals() |
| | 39 | if not _initialised: |
| | 40 | from django.conf import settings |
| | 41 | if settings.USE_I18N: |
| | 42 | import trans_real as trans |
| | 43 | else: |
| | 44 | import trans_null as trans |
| | 45 | for name in __all__: |
| | 46 | if hasattr(trans, name): |
| | 47 | g['real_%s' % name] = getattr(trans, name) |
| | 48 | _initialised = True |
| | 49 | |
| | 50 | # Make the originally requested function call on the way out the door. |
| | 51 | return g[caller](*args, **kwargs) |
| | 52 | finally: |
| | 53 | _init_lock.release() |
| 43 | 54 | |
| 44 | 55 | g = globals() |
| 45 | 56 | for name in __all__: |