Browse Source

Set locale automatically during the first run

Closes #235
See also: c4fa38ba8b
doc-issue-template
MrS0m30n3 7 years ago
parent
commit
c4b012d2c8
2 changed files with 16 additions and 2 deletions
  1. 5
      youtube_dl_gui/optionsmanager.py
  2. 13
      youtube_dl_gui/utils.py

5
youtube_dl_gui/optionsmanager.py

@ -13,7 +13,8 @@ from .utils import (
os_path_exists,
encode_tuple,
decode_tuple,
check_path
check_path,
get_default_lang
)
from .formats import (
@ -282,7 +283,7 @@ class OptionsManager(object):
'enable_log': True,
'log_time': True,
'workers_number': 3,
'locale_name': 'en_US',
'locale_name': get_default_lang(),
'main_win_size': (740, 490),
'opts_win_size': (640, 490),
'selected_video_formats': ['webm', 'mp4'],

13
youtube_dl_gui/utils.py

@ -116,6 +116,9 @@ os_path_abspath = convert_on_bounds(os.path.abspath)
os_path_realpath = convert_on_bounds(os.path.realpath)
os_path_expanduser = convert_on_bounds(os.path.expanduser)
# Patch locale functions
locale_getdefaultlocale = convert_on_bounds(locale.getdefaultlocale)
# Patch Windows specific functions
if os.name == 'nt':
os_startfile = convert_on_bounds(os.startfile)
@ -376,3 +379,13 @@ def build_command(options_list, url):
url = "\"{}\"".format(url)
return " ".join([YOUTUBEDL_BIN] + options + [url])
def get_default_lang():
"""Get default language using the 'locale' module."""
default_lang, _ = locale_getdefaultlocale()
if not default_lang:
default_lang = "en_US"
return default_lang
Loading…
Cancel
Save