def get_default_locale_callable():
 exec_dir = os.path.dirname(os.path.realpath(__file__))
 xml_path = os.path.join(exec_dir, 'data', 'FacebookLocales.xml')
 fb_locales = _build_locale_table(xml_path)
 def default_locale(request):
  "\n        Guess an appropiate FB locale based on the active Django locale.\n        If the active locale is available, it is returned. Otherwise,\n        it tries to return another locale with the same language. If there\n        isn't one avaible, 'en_US' is returned.\n        "
  chosen = 'en_US'
  language = get_language()
  if language:
   locale = to_locale(language)
   (lang, _, reg) = locale.partition('_')
   lang_map = fb_locales.get(lang)
   if (lang_map is not None):
    if (reg in lang_map['regs']):
     chosen = ((lang + '_') + reg)
    else:
     chosen = ((lang + '_') + lang_map['default'])
  return chosen
 return default_locale

def get_default_locale_callable ( ) : exec_dir = os . path . dirname ( os . path . realpath ( __file__ ) ) xml_path = os . path . join ( exec_dir , 'data' , 'FacebookLocales.xml' ) fb_locales = _build_locale_table ( xml_path ) def default_locale ( request ) : chosen = 'en_US' language = get_language ( ) if language : locale = to_locale ( language ) ( lang , _ , reg ) = locale . partition ( '_' ) lang_map = fb_locales . get ( lang ) if ( lang_map is not None ) : if ( reg in lang_map [ 'regs' ] ) : chosen = ( ( lang + '_' ) + reg ) else : chosen = ( ( lang + '_' ) + lang_map [ 'default' ] ) return chosen return default_locale
wrapper function so that the default mapping is only built when needed .