docs: def _build_locale_table(filename_or_file):
      """
      Parses the FacebookLocales.xml file and builds a dict relating every
      available language ('en, 'es, 'zh', ...) with a list of available regions
      for that language ('en' -> 'US', 'EN') and an (arbitrary) default region.
      """
      # Require the XML parser module only if we want the default mapping
      from xml.dom.minidom import parse
  
      dom = parse(filename_or_file)
  
      reps = dom.getElementsByTagName('representation')
      locs = map(lambda r: r.childNodes[0].data, reps)
  
      locale_map = {}
      for loc in locs:
          lang, _, reg = loc.partition('_')
          lang_map = locale_map.setdefault(lang, {'regs': [], 'default': reg})
          lang_map['regs'].append(reg)
  
      # Default region overrides (arbitrary)
      locale_map['en']['default'] = 'US'
      # Special case: Use es_ES for Spain and es_LA for everything else
      locale_map['es']['default'] = 'LA'
      locale_map['zh']['default'] = 'CN'
      locale_map['fr']['default'] = 'FR'
      locale_map['pt']['default'] = 'PT'
  
      return locale_map