From e3f537770f5282b7629e880caa282989c86ebc89 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Wed, 5 Jul 2017 10:02:54 +0100 Subject: [PATCH] [UI] Fix setting gettext to unicode for Py2 compat --- deluge/ui/translations_util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deluge/ui/translations_util.py b/deluge/ui/translations_util.py index 61f7f28f8..2491609bc 100644 --- a/deluge/ui/translations_util.py +++ b/deluge/ui/translations_util.py @@ -122,7 +122,11 @@ def setup_translations(setup_gettext=True, setup_pygtk=False): gettext.bindtextdomain(domain, translations_path) gettext.bind_textdomain_codeset(domain, 'UTF-8') gettext.textdomain(domain) - gettext.install(domain, translations_path, names='ngettext') + + # Workaround for Python 2 unicode gettext (keyword removed in Py3). + kwargs = {} if not deluge.common.PY2 else {'unicode': True} + + gettext.install(domain, translations_path, names='ngettext', **kwargs) __builtin__.__dict__['_n'] = __builtin__.__dict__['ngettext'] except Exception as ex: log.error('Unable to initialize gettext/locale!')