Curated list of languages spoken in Africa
# afriso π
**Map African language names to ISO 639-3 codes, countries, families, and alternative names β and back.**
`afriso` is a small, dependency-free Python library for anyone working with
African languages in data-processing and NLP tasks. Look a language up by name,
alternative name, or code; filter by country, region, or language family; and
export the result to dicts, JSON, CSV, or a pandas DataFrame.
It covers **2,264 languages** spoken across **58 African countries and
territories**, grouped into **58 language families**, with alternative names for
**2,114** of them β including the widely-used **macrolanguage** codes (Swahili
`swa`, Akan `aka`, Oromo `orm`, Fulah `ful`, β¦).
Built entirely from open sources: the **SIL ISO 639-3** code tables and
**Glottolog** (CC-BY 4.0). No proprietary Ethnologue data.
## Install
```bash
pip install afriso # core library, zero dependencies
pip install "afriso[pandas]" # optional: enables .to_dataframe()
```
## Quick start
```python
import afriso
# Names codes (case-insensitive; accepts names, alt names, and codes)
afriso.to_iso("Yoruba") # 'yor'
afriso.to_iso("Yariba") # 'yor' (alternative name)
afriso.to_name("hau") # 'Hausa'
afriso.to_name("sw") # 'Swahili (macrolanguage)' (ISO 639-1 works too)
# Full record
lang = afriso.get("Bambara")
lang.iso639_3 # 'bam'
lang.family # 'Mande'
lang.countries # ('CI', 'GN', 'ML', 'SN')
lang.regions # ('West Africa',)
lang.alt_names # ('Bamana', 'Bamanakan', 'Bamanankan')
lang.glottocode # 'bamb1269'
```
## Filter & group
```python
afriso.by_country("Nigeria") # LanguageSet of 568 languages
afriso.by_country("NG") # same β alpha-2, alpha-3, or name
afriso.by_region("West Africa") # region grouping
afriso.by_family("Mande") # by language family
# Chain filters
afriso.by_region("West Africa").by_family("Mande").names()
# ['Bambara', 'Bandi' β¦