Skip to content

Commit

Permalink
setup: be more tolerant towards unknown languages, follow pycountry c…
Browse files Browse the repository at this point in the history
…hanges
  • Loading branch information
chrysn committed Jan 21, 2019
1 parent da0ebac commit dfde50b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ def language2name(lang):
lang, country = lang.split('_')
else:
country = None
lang = pycountry.languages.get(alpha2=lang).name
try:
lang = pycountry.languages.get(alpha_2=lang).name
except KeyError:
pass # eg. "ckb"

try:
# strip suffixes like 'Catalan; Valencian'
Expand All @@ -165,7 +168,10 @@ def language2name(lang):
pass

if country:
country = pycountry.countries.get(alpha2=country).name
try:
country = pycountry.countries.get(alpha_2=country).name
except KeyError:
pass # keep country, eg. zh-Hant, whatever that means in detail
return u"%s (%s)"%(lang, country)
else:
return lang
Expand Down

0 comments on commit dfde50b

Please sign in to comment.