mirror of
https://github.com/jellyfin/jellyfin-mpv-shim.git
synced 2025-02-24 08:30:47 +00:00
Improve language detection. (Not tested yet.)
This commit is contained in:
parent
0b422624fd
commit
d5835f027d
@ -1,5 +1,6 @@
|
||||
import gettext
|
||||
import builtins
|
||||
import locale
|
||||
|
||||
from .conf import settings
|
||||
|
||||
@ -10,9 +11,19 @@ def configure():
|
||||
global translation
|
||||
from .utils import get_resource
|
||||
messages_dir = get_resource("messages")
|
||||
lang = None
|
||||
|
||||
if settings.lang is not None:
|
||||
translation = gettext.translation("base", messages_dir, languages=[settings.lang], fallback=True)
|
||||
lang = settings.lang
|
||||
else:
|
||||
# This is more robust than the built-in language detection in gettext.
|
||||
# Specifically, it supports Windows correctly.
|
||||
lc = locale.getdefaultlocale()
|
||||
if lc is not None and lc[0] is not None:
|
||||
lang = lc[0]
|
||||
|
||||
if lang is not None:
|
||||
translation = gettext.translation("base", messages_dir, languages=[lang], fallback=True)
|
||||
else:
|
||||
translation = gettext.translation("base", messages_dir, fallback=True)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user