def locale_and_slug_from_path(path, request=None, path_locale=None):
 (locale, slug, needs_redirect) = ('', path, False)
 mdn_languages_lower = dict(((x.lower(), x) for x in settings.MDN_LANGUAGES))
 if ('/' in path):
  (maybe_locale, maybe_slug) = path.split('/', 1)
  l_locale = maybe_locale.lower()
  if (l_locale in settings.MT_TO_KUMA_LOCALE_MAP):
   needs_redirect = True
   locale = settings.MT_TO_KUMA_LOCALE_MAP[l_locale]
   slug = maybe_slug
  elif (l_locale in mdn_languages_lower):
   needs_redirect = True
   locale = mdn_languages_lower[l_locale]
   slug = maybe_slug
 if (locale == ''):
  if request:
   locale = request.LANGUAGE_CODE
  elif path_locale:
   locale = path_locale
 if (locale == ''):
  locale = getattr(settings, 'WIKI_DEFAULT_LANGUAGE', 'en-US')
 return (locale, slug, needs_redirect)

def locale_and_slug_from_path ( path , request = None , path_locale = None ) : ( locale , slug , needs_redirect ) = ( '' , path , False ) mdn_languages_lower = dict ( ( ( x . lower ( ) , x ) for x in settings . MDN_LANGUAGES ) ) if ( '/' in path ) : ( maybe_locale , maybe_slug ) = path . split ( '/' , 1 ) l_locale = maybe_locale . lower ( ) if ( l_locale in settings . MT_TO_KUMA_LOCALE_MAP ) : needs_redirect = True locale = settings . MT_TO_KUMA_LOCALE_MAP [ l_locale ] slug = maybe_slug elif ( l_locale in mdn_languages_lower ) : needs_redirect = True locale = mdn_languages_lower [ l_locale ] slug = maybe_slug if ( locale == '' ) : if request : locale = request . LANGUAGE_CODE elif path_locale : locale = path_locale if ( locale == '' ) : locale = getattr ( settings , 'WIKI_DEFAULT_LANGUAGE' , 'en-US' ) return ( locale , slug , needs_redirect )
given a proposed doc path .