def format_navigation_links(additional_languages, default_lang, messages, strip_indexes=False):
 f = u'    {0}: (\n        ("{1}/archive.html", "{2[Archive]}"),\n        ("{1}/categories/{3}", "{2[Tags]}"),\n        ("{1}/rss.xml", "{2[RSS feed]}"),\n    ),'
 pairs = []
 def get_msg(lang):
  u'Generate a smaller messages dict with fallback.'
  fmsg = {}
  for i in (u'Archive', u'Tags', u'RSS feed'):
   if messages[lang][i]:
    fmsg[i] = messages[lang][i]
   else:
    fmsg[i] = i
  return fmsg
 if strip_indexes:
  index_html = u''
 else:
  index_html = u'index.html'
 pairs.append(f.format(u'DEFAULT_LANG', u'', get_msg(default_lang), index_html))
 for l in additional_languages:
  pairs.append(f.format(json.dumps(l, ensure_ascii=False), (u'/' + l), get_msg(l), index_html))
 return u'{{\n{0}\n}}'.format(u'\n\n'.join(pairs))

def format_navigation_links ( additional_languages , default_lang , messages , strip_indexes = False ) : f = u'    {0}: (\n        ("{1}/archive.html", "{2[Archive]}"),\n        ("{1}/categories/{3}", "{2[Tags]}"),\n        ("{1}/rss.xml", "{2[RSS feed]}"),\n    ),' pairs = [ ] def get_msg ( lang ) : fmsg = { } for i in ( u'Archive' , u'Tags' , u'RSS feed' ) : if messages [ lang ] [ i ] : fmsg [ i ] = messages [ lang ] [ i ] else : fmsg [ i ] = i return fmsg if strip_indexes : index_html = u'' else : index_html = u'index.html' pairs . append ( f . format ( u'DEFAULT_LANG' , u'' , get_msg ( default_lang ) , index_html ) ) for l in additional_languages : pairs . append ( f . format ( json . dumps ( l , ensure_ascii = False ) , ( u'/' + l ) , get_msg ( l ) , index_html ) ) return u'{{\n{0}\n}}' . format ( u'\n\n' . join ( pairs ) )
return the string to configure navigation_links .