Skip to content

Commit

Permalink
Merge pull request #50 from devleaks/main
Browse files Browse the repository at this point in the history
locale.getdefaultlocale() is deprecated and returns unhandled values
  • Loading branch information
mivek authored Aug 5, 2023
2 parents c8b628b + a0d8ea2 commit 424580a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion metar_taf_parser/commons/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../locale')
langAvailable = os.listdir(localedir)
lang = locale.getdefaultlocale()[0][:2]
loc = locale.getlocale()
lang = 'en'
if loc is not None and loc[0] is not None and len(loc[0]) >= 2:
lang = loc[0][:2]
if lang not in langAvailable:
lang = 'en'
t = gettext.translation(domain='messages', localedir=localedir, fallback=True, languages=[lang])
Expand Down

0 comments on commit 424580a

Please sign in to comment.