diff --git a/youtube_dl_gui/optionsmanager.py b/youtube_dl_gui/optionsmanager.py index 291c021..a36b64e 100644 --- a/youtube_dl_gui/optionsmanager.py +++ b/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'], diff --git a/youtube_dl_gui/utils.py b/youtube_dl_gui/utils.py index a966ae8..729c007 100644 --- a/youtube_dl_gui/utils.py +++ b/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