Skip to content

Commit

Permalink
set default and try ... except modes for check lang environemment
Browse files Browse the repository at this point in the history
  • Loading branch information
Furtif committed Dec 30, 2023
1 parent 8da9c0d commit a4fe056
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions options.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ def get_last_error():
return err


def translator(filename):
def translator(domain):
# default translation if err set to en_US
check = 'en_US'
try:
lang, enc = locale.getlocale()
os.environ['LANG'] = lang
check = lang
except:
# defaul tranlation if err en_US
os.environ["LANG"] = 'fr_FR'
try:
lang, enc = locale.getdefaultlocale()
check = lang
except:
pass
pass
os.environ['LANG'] = check

# Set up message catalog access
t = gettext.translation(filename, 'dtt4all_data/locale', fallback=True) # not ok in python 3.11.x, codeset="utf-8")
t = gettext.translation(domain, 'dtt4all_data/locale', fallback=True) # not ok in python 3.11.x, codeset="utf-8")
return t.gettext

0 comments on commit a4fe056

Please sign in to comment.