mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-22 06:13:25 -07:00
Refactored the changes into a cleaner code with comments (#2345)
This commit is contained in:
parent
6dc53da8bf
commit
e673c599bb
1 changed files with 13 additions and 3 deletions
16
Tautulli.py
16
Tautulli.py
|
@ -71,19 +71,29 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
# Attempt to get the system's locale settings
|
||||||
language_code, encoding = locale.getlocale()
|
language_code, encoding = locale.getlocale()
|
||||||
|
|
||||||
|
# If encoding is not returned, get the encoding
|
||||||
if not encoding:
|
if not encoding:
|
||||||
encoding = locale.getencoding()
|
encoding = locale.getencoding()
|
||||||
|
|
||||||
# Special case for Windows where getlocale doesn't return correctly
|
# Special handling for Windows platform
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
# Get the kernel of the OS and the default UI Language to locate the language code in Windows
|
# Get the user's default UI language on Windows
|
||||||
windll = ctypes.windll.kernel32
|
windll = ctypes.windll.kernel32
|
||||||
language_code = locale.windows_locale[windll.GetUserDefaultUILanguage()]
|
lang_id = windll.GetUserDefaultUILanguage()
|
||||||
|
|
||||||
|
# Map Windows language ID to locale identifier
|
||||||
|
language_code = locale.windows_locale.get(lang_id, '')
|
||||||
|
|
||||||
|
# Set encoding to Windows default encoding
|
||||||
encoding = "cp1252"
|
encoding = "cp1252"
|
||||||
|
|
||||||
|
# Assign values to application-specific variable
|
||||||
plexpy.SYS_LANGUAGE = language_code
|
plexpy.SYS_LANGUAGE = language_code
|
||||||
plexpy.SYS_ENCODING = encoding
|
plexpy.SYS_ENCODING = encoding
|
||||||
|
|
||||||
except (locale.Error, IOError):
|
except (locale.Error, IOError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue