khof312's picture
Fix issue with Moore/Mossi.
30539df
raw
history blame
521 Bytes
import pycountry
iso_encoder = {"English":"eng",
"French":"fra",
"Moore": "mos"}
iso_decoder = dict((v,k) for k,v in iso_encoder.items())
def encode_iso(lang:str)-> str:
''' Takes the name of a language and returns its ISO-3 code. '''
return iso_encoder[lang]
def decode_iso(iso:str)-> str:
''' Takes an ISO-3 code and returns the name of the language. '''
name = pycountry.languages.get(alpha_3 = iso).name
name = name.replace("Mossi", "Mooré")
return name