# HG changeset patch # User Marcin Kuzminski # Date 2017-07-12 16:51:01 # Node ID 1a7936c38827a3a11f9204201e0dca902aad0607 # Parent 982ccdbd46c22b53e10d7f3461fd4cdf79163119 pyramid: move language extraction into a seperate method. diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -271,6 +271,16 @@ def calculate_version_hash(): rhodecode.__version__)[:8] +def get_current_lang(request): + # NOTE(marcink): remove after pyramid move + try: + return translation.get_lang()[0] + except: + pass + + return getattr(request, '_LOCALE_', None) + + def attach_context_attributes(context, request, user_id): """ Attach variables into template context called `c`, please note that @@ -284,7 +294,7 @@ def attach_context_attributes(context, r context.rhodecode_version_hash = calculate_version_hash() # Default language set for the incoming request - context.language = translation.get_lang()[0] + context.language = get_current_lang(request) # Visual options context.visual = AttributeDict({})