aboutsummaryrefslogtreecommitdiffstats
path: root/community/gnome-authenticator/dont-require-py3-gettext-support.patch
blob: 0612747d1d25263b5058d3dd0db1979f3e399fac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Upstream: Pending, https://gitlab.gnome.org/World/Authenticator/-/merge_requests/160
From 4073b3f3d97f0c4d74a7017da181fb4e41bdef8e Mon Sep 17 00:00:00 2001
From: Rasmus Thomsen <oss@cogitri.dev>
Date: Wed, 8 Jul 2020 18:08:16 +0200
Subject: [PATCH] Gracefully handle locale.{bind,}textdomain not being
 available

When python is built without gettext support these functions aren't
available and as such GTG fails to start without this change.
---
 src/authenticator.py.in | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/authenticator.py.in b/src/authenticator.py.in
index 1e75e10..2cc371f 100755
--- a/src/authenticator.py.in
+++ b/src/authenticator.py.in
@@ -35,8 +35,15 @@ from gi.repository import Gio, Handy
 sys.path.insert(1, '@PYTHON_DIR@')
 
 def prepare_locale():
-    locale.bindtextdomain('@GETTEXT_PACKAGE@', '@LOCALE_DIR@')
-    locale.textdomain('@GETTEXT_PACKAGE@')
+    try:
+        locale.bindtextdomain('@GETTEXT_PACKAGE@', '@LOCALE_DIR@')
+        locale.textdomain('@GETTEXT_PACKAGE@')
+    except AttributeError as e:
+        # Python built without gettext support doesn't have bindtextdomain()
+        # and textdomain()
+        print("Couldn't bind the gettext translation domain. Some translations"
+        " won't work.\n{}".format(e))
+
     gettext.bindtextdomain('@GETTEXT_PACKAGE@', '@LOCALE_DIR@')
     gettext.textdomain('@GETTEXT_PACKAGE@')
 
-- 
GitLab