diff options
author | Calum Lind <calumlind@gmail.com> | 2018-10-13 22:49:10 +0100 |
---|---|---|
committer | Calum Lind <calumlind@gmail.com> | 2018-10-13 22:57:28 +0100 |
commit | 10d39c83cbde62fa9c3b7ac24dab17131ac25180 (patch) | |
tree | 4bb6f626c2d5b0a1313ef0d61f0d31361c639da2 /deluge/ui/web | |
parent | 0b2cb7539ff5b321fe285f47c9b7617653471d7a (diff) | |
download | deluge-10d39c83cbde62fa9c3b7ac24dab17131ac25180.tar.gz deluge-10d39c83cbde62fa9c3b7ac24dab17131ac25180.tar.bz2 deluge-10d39c83cbde62fa9c3b7ac24dab17131ac25180.zip |
[WebUI] Fix error escaping translated text
In a previous commit d4023e7dde42 removed a decode for Python 3 but
with translated text returned by gettext encoded on Python 2 the
escape function would raise a UnicodeDecodeError trying to use ascii
to decode.
The fix is to decode the message returned by gettext on Python 2.
Diffstat (limited to 'deluge/ui/web')
-rw-r--r-- | deluge/ui/web/common.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/deluge/ui/web/common.py b/deluge/ui/web/common.py index 0935e2f57..de0afb76c 100644 --- a/deluge/ui/web/common.py +++ b/deluge/ui/web/common.py @@ -12,11 +12,14 @@ from __future__ import unicode_literals import gettext import zlib -from deluge import common +from deluge.common import PY2, get_version def _(text): - return gettext.gettext(text) + text_local = gettext.gettext(text) + if PY2: + return text_local.decode('utf-8') + return text_local def escape(text): @@ -51,7 +54,7 @@ try: A template that adds some built-ins to the rendering """ - builtins = {'_': _, 'escape': escape, 'version': common.get_version()} + builtins = {'_': _, 'escape': escape, 'version': get_version()} def render(self, *args, **data): data.update(self.builtins) |