def translate_url(url, lang_code):
 parsed = urlsplit(url)
 try:
  match = resolve(parsed.path)
 except Resolver404:
  pass
 else:
  to_be_reversed = (('%s:%s' % (match.namespace, match.url_name)) if match.namespace else match.url_name)
  with override(lang_code):
   try:
    url = reverse(to_be_reversed, args=match.args, kwargs=match.kwargs)
   except NoReverseMatch:
    pass
   else:
    url = urlunsplit((parsed.scheme, parsed.netloc, url, parsed.query, parsed.fragment))
 return url

def translate_url ( url , lang_code ) : parsed = urlsplit ( url ) try : match = resolve ( parsed . path ) except Resolver404 : pass else : to_be_reversed = ( ( '%s:%s' % ( match . namespace , match . url_name ) ) if match . namespace else match . url_name ) with override ( lang_code ) : try : url = reverse ( to_be_reversed , args = match . args , kwargs = match . kwargs ) except NoReverseMatch : pass else : url = urlunsplit ( ( parsed . scheme , parsed . netloc , url , parsed . query , parsed . fragment ) ) return url
translates the current url for the given language code .