|
@@ -3,6 +3,7 @@ import os
|
3
|
3
|
import time
|
4
|
4
|
import signal
|
5
|
5
|
|
|
6
|
+import tg
|
6
|
7
|
from tg import config
|
7
|
8
|
from tg import require
|
8
|
9
|
from tg import response
|
|
@@ -150,12 +151,17 @@ def _lazy_ugettext(text: str):
|
150
|
151
|
:return: lazyfied string or string
|
151
|
152
|
"""
|
152
|
153
|
try:
|
153
|
|
- # Test if context is available,
|
|
154
|
+ # Test if tg.translator is defined
|
|
155
|
+ #
|
154
|
156
|
# cf. https://github.com/tracim/tracim/issues/173
|
155
|
|
- context = StackedObjectProxy(name="context")
|
156
|
|
- context.translator
|
|
157
|
+ #
|
|
158
|
+ # HACK - 2017-11-03 - D.A
|
|
159
|
+ # Replace context proxyfied by direct access to gettext function
|
|
160
|
+ # which is not setup in case the tg2 context is not initialized
|
|
161
|
+ tg.translator.gettext # raises a TypeError exception if context not set
|
157
|
162
|
return ugettext(text)
|
158
|
|
- except TypeError:
|
|
163
|
+ except TypeError as e:
|
|
164
|
+ logger.debug(_lazy_ugettext, 'TG2 context not available for translation. TypeError: {}'.format(e))
|
159
|
165
|
return text
|
160
|
166
|
|
161
|
167
|
lazy_ugettext = lazify(_lazy_ugettext)
|