Skip to content

Commit

Permalink
Attempt to fix locale load crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Dec 2, 2023
1 parent 3d1066e commit b7726dd
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions skytemple/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,24 @@
if failed_to_set_locale:
failed_to_set_locale = False

lang, env = locale.getlocale()
lang, enc = locale.getlocale()
print(
f"WARNING: Failed processing current locale {lang}.{env}. Falling back to {lang}"
f"WARNING: Failed processing current locale {lang}.{enc}. Falling back to {lang}"
)
os.environ["LANG"] = lang
ctypes.cdll.msvcrt._putenv(f"LANG={lang}")
try:
locale.setlocale(locale.LC_ALL, lang)
except:
failed_to_set_locale = True

try:
locale.getlocale()
except:
# If this returns None for lang, then we bail!
if lang is not None:
os.environ["LANG"] = lang
ctypes.cdll.msvcrt._putenv(f"LANG={lang}")
try:
locale.setlocale(locale.LC_ALL, lang)
except:
failed_to_set_locale = True

try:
locale.getlocale()
except:
failed_to_set_locale = True
else:
failed_to_set_locale = True

if failed_to_set_locale:
Expand Down

0 comments on commit b7726dd

Please sign in to comment.