diff options
author | Michael Weiser <michael.weiser@gmx.de> | 2019-04-08 15:17:53 +0000 |
---|---|---|
committer | Michael Weiser <michael.weiser@gmx.de> | 2019-04-08 16:51:18 +0000 |
commit | a383e1b7d9e816991a36ba23e5d22f85d2a6d387 (patch) | |
tree | 74d0f4d4ae2055021e60aa76454ee12538991ec8 /peekaboo | |
parent | 640bc1ad05467e0c9974c8fd1a0976b03d473a1e (diff) |
Force gettext to use unicode on python2
On python2 gettext returns str() which is not unicode() there and causes
those feared encoding errors if anything formatted into those translated
strings is not ascii. Force gettext to return unicode strings but only
on python2 because it's default on python3 anyway and the respective
parameters doesn't exist there.
Diffstat (limited to 'peekaboo')
-rw-r--r-- | peekaboo/daemon.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/peekaboo/daemon.py b/peekaboo/daemon.py index 736f883..bc77580 100644 --- a/peekaboo/daemon.py +++ b/peekaboo/daemon.py @@ -271,7 +271,11 @@ def run(): logger.debug('Installing report message translations') translation = gettext.translation(locale_domain, locale_dir, languages, fallback=True) - translation.install() + # python2's gettext needs to be told explicitly to return unicode strings + loc_kwargs = {} + if sys.version_info[0] < 3: + loc_kwargs = {'unicode': True} + translation.install(loc_kwargs) # establish a connection to the database try: |