From bf8c5886ed3d4f6b15a901faa40e723e71cae85c Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Wed, 2 Dec 2015 15:08:17 +0800 Subject: [PATCH] [utils] Detect language on Windows --- youtube_dl/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 7dc32e85e..3bc85ded0 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2518,11 +2518,15 @@ def g(s): gettext.textdomain('youtube_dl') gettext.bindtextdomain('youtube_dl', localedir='share/locale/') - ret = gettext.gettext(s) + lang, _ = locale.getdefaultlocale() + try: + t = gettext.translation('youtube_dl', 'share/locale/', [lang]) + except (OSError, IOError): # OSError for 3.3+ and IOError otherwise + return s + ret = t.gettext(s) if isinstance(ret, bytes): ret = ret.decode('utf-8') - return ret