Skip to content

Commit

Permalink
Mypy: Return early with default if locale setting is None
Browse files Browse the repository at this point in the history
  • Loading branch information
jwijenbergh authored and gijzelaerr committed May 9, 2022
1 parent 41234f8 commit 353c736
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions eduvpn/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ def setup(app_variant: ApplicationVariant, prefix: str):

def country() -> str:
try:
return locale.getlocale()[0].replace('_', '-')
locale_setting = locale.getlocale()[0]
if not locale_setting:
return COUNTRY
return locale_setting.replace('_', '-')
except Exception:
return COUNTRY


def language() -> str:
try:
return locale.getlocale()[0].split('_')[0]
locale_setting = locale.getlocale()[0]
if not locale_setting:
return LANGUAGE
return locale_setting.split('_')[0]
except Exception:
return LANGUAGE

Expand Down

0 comments on commit 353c736

Please sign in to comment.