def get_official_languages(territory, regional=False, de_facto=False):
 territory = str(territory).upper()
 allowed_stati = set(('official',))
 if regional:
  allowed_stati.add('official_regional')
 if de_facto:
  allowed_stati.add('de_facto_official')
 languages = get_global('territory_languages').get(territory, {})
 pairs = [(info['population_percent'], language) for (language, info) in languages.items() if (info.get('official_status') in allowed_stati)]
 pairs.sort(reverse=True)
 return tuple((lang for (_, lang) in pairs))

def get_official_languages ( territory , regional = False , de_facto = False ) : territory = str ( territory ) . upper ( ) allowed_stati = set ( ( 'official' , ) ) if regional : allowed_stati . add ( 'official_regional' ) if de_facto : allowed_stati . add ( 'de_facto_official' ) languages = get_global ( 'territory_languages' ) . get ( territory , { } ) pairs = [ ( info [ 'population_percent' ] , language ) for ( language , info ) in languages . items ( ) if ( info . get ( 'official_status' ) in allowed_stati ) ] pairs . sort ( reverse = True ) return tuple ( ( lang for ( _ , lang ) in pairs ) )
get the official language(s) for the given territory .