| 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() |
|---|