Show More
@@ -443,20 +443,12 b' class BaseController(WSGIController):' | |||
|
443 | 443 | self.sa = meta.Session |
|
444 | 444 | self.scm_model = ScmModel(self.sa) |
|
445 | 445 | |
|
446 |
|
|
|
447 | user_lang = c.language | |
|
448 |
|
|
|
449 | user_obj = self._rhodecode_user.get_instance() | |
|
450 | if user_obj: | |
|
451 | user_lang = user_obj.user_data.get('language') | |
|
452 | except Exception: | |
|
453 | log.exception('Failed to fetch user language for user %s', | |
|
454 | self._rhodecode_user) | |
|
455 | ||
|
456 | if user_lang and user_lang != default_lang: | |
|
457 | log.debug('set language to %s for user %s', user_lang, | |
|
458 | self._rhodecode_user) | |
|
446 | # set user language | |
|
447 | user_lang = getattr(c.pyramid_request, '_LOCALE_', None) | |
|
448 | if user_lang: | |
|
459 | 449 | translation.set_lang(user_lang) |
|
450 | log.debug('set language to %s for user %s', | |
|
451 | user_lang, self._rhodecode_user) | |
|
460 | 452 | |
|
461 | 453 | def _dispatch_redirect(self, with_url, environ, start_response): |
|
462 | 454 | resp = HTTPFound(with_url) |
@@ -63,6 +63,15 b' def add_localizer(event):' | |||
|
63 | 63 | request.plularize = localizer.pluralize |
|
64 | 64 | |
|
65 | 65 | |
|
66 | def set_user_lang(event): | |
|
67 | cur_user = getattr(event.request, 'user', None) | |
|
68 | ||
|
69 | if cur_user: | |
|
70 | user_lang = cur_user.get_instance().user_data.get('language') | |
|
71 | if user_lang: | |
|
72 | event.request._LOCALE_ = user_lang | |
|
73 | ||
|
74 | ||
|
66 | 75 | def scan_repositories_if_enabled(event): |
|
67 | 76 | """ |
|
68 | 77 | This is subscribed to the `pyramid.events.ApplicationCreated` event. It |
@@ -67,8 +67,7 b' def pylons_compatibility_tween_factory(h' | |||
|
67 | 67 | session_key = ( |
|
68 | 68 | config['pylons.environ_config'].get('session', 'beaker.session')) |
|
69 | 69 | environ[session_key] = session |
|
70 | pylons.url._push_object(URLGenerator(config['routes.map'], | |
|
71 | environ)) | |
|
70 | pylons.url._push_object(URLGenerator(config['routes.map'], environ)) | |
|
72 | 71 | |
|
73 | 72 | # TODO: Maybe we should use the language from pyramid. |
|
74 | 73 | translator = _get_translator(config.get('lang')) |
@@ -92,6 +91,8 b' def pylons_compatibility_tween_factory(h' | |||
|
92 | 91 | def includeme(config): |
|
93 | 92 | config.add_subscriber('rhodecode.subscribers.add_renderer_globals', |
|
94 | 93 | 'pyramid.events.BeforeRender') |
|
94 | config.add_subscriber('rhodecode.subscribers.set_user_lang', | |
|
95 | 'pyramid.events.NewRequest') | |
|
95 | 96 | config.add_subscriber('rhodecode.subscribers.add_localizer', |
|
96 | 97 | 'pyramid.events.NewRequest') |
|
97 | 98 | config.add_tween('rhodecode.tweens.pylons_compatibility_tween_factory') |
General Comments 0
You need to be logged in to leave comments.
Login now