Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Bug fix for config/i18n.py translator() using unsafe call get_current_request() #608

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+9 −3
Split
View
@@ -119,8 +119,14 @@ def register():
self.action(None, register, introspectables=introspectables)
-def translator(msg):
- request = get_current_request()
+def translator(msg, context = None):
+ request = None
+ if context:
+ try:
+ request = context['request']
+ except Exception:
+ pass
+ if not request:
+ request = get_current_request()
localizer = get_localizer(request)
return localizer.translate(msg)
-