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