aboutsummaryrefslogtreecommitdiffstats
path: root/testing/getting-things-gnome/dont-require-py3-gettext.patch
blob: c3a5a76db3f1d2cb37f203b91e5d8edaa367a3b8 (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
Upstream: Pending, https://github.com/getting-things-gnome/gtg/pull/387
From a03b68f636f21a92922aff9be2b3b728a4bcd52f Mon Sep 17 00:00:00 2001
From: Rasmus Thomsen <oss@cogitri.dev>
Date: Thu, 2 Jul 2020 09:27:37 +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.
---
 GTG/gtg.in | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/GTG/gtg.in b/GTG/gtg.in
index a4ea12df..ea310186 100755
--- a/GTG/gtg.in
+++ b/GTG/gtg.in
@@ -99,8 +99,17 @@ if __name__ == "__main__":
 
         # Set up UI i18n
         LOCALE_DIR = '@localedir@'
-        locale.bindtextdomain('gtg', LOCALE_DIR)
-        locale.textdomain('gtg')
+
+        try:
+            locale.bindtextdomain('gtg', LOCALE_DIR)
+            locale.textdomain('gtg')
+        except AttributeError as e:
+            # Python built without gettext support doesn't have bindtextdomain()
+            # and textdomain(), so gracefully fail here.
+            print(
+                "Couldn't bind the translation domain. Some translations won't "
+            "work.\n{}".format(e))
+
         gettext.bindtextdomain('gtg', LOCALE_DIR)
         gettext.textdomain('gtg')