1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Detect LANG for gettext on android

This commit is contained in:
Juhani Numminen 2019-08-12 12:28:43 +03:00
parent 8bef9848a5
commit 93c9535216

View file

@ -27,6 +27,11 @@ import os
import subprocess import subprocess
import sys import sys
try:
import jnius
except ImportError:
jnius = None
import pysollib.settings import pysollib.settings
# ************************************************************************ # ************************************************************************
@ -36,13 +41,14 @@ import pysollib.settings
def init(): def init():
if os.name == 'nt' and 'LANG' not in os.environ: if 'LANG' not in os.environ:
try: if os.name == 'nt':
loc = locale.getdefaultlocale() lang, enc = locale.getdefaultlocale()
os.environ['LANG'] = loc[0] os.environ['LANG'] = lang
except Exception: elif jnius: # android
pass Locale = jnius.autoclass('java.util.Locale')
# locale.setlocale(locale.LC_ALL, '') os.environ['LANG'] = Locale.getDefault().getLanguage()
locale.setlocale(locale.LC_ALL, '')
# install gettext # install gettext
# locale_dir = 'locale' # locale_dir = 'locale'