summaryrefslogtreecommitdiffstats
path: root/recipes-security/selinux/selinux-gui/0001-gettext-handle-unsupported-languages-properly.patch
blob: d79db2269616067aa1e92b8bc6b400eebbf160e8 (plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
From a0a67119412622141a7f8365eff10de6395be7ca Mon Sep 17 00:00:00 2001
From: Vit Mojzis <vmojzis@redhat.com>
Date: Fri, 24 Jun 2022 16:24:25 +0200
Subject: [PATCH] gettext: handle unsupported languages properly

With "fallback=True" gettext.translation behaves the same as
gettext.install and uses NullTranslations in case the
translation file for given language was not found (as opposed to
throwing an exception).

Fixes:
  # LANG is set to any "unsupported" language, e.g. en_US.UTF-8
  $ chcat --help
  Traceback (most recent call last):
  File "/usr/bin/chcat", line 39, in <module>
    t = gettext.translation(PROGNAME,
  File "/usr/lib64/python3.9/gettext.py", line 592, in translation
    raise FileNotFoundError(ENOENT,
  FileNotFoundError: [Errno 2] No translation file found for domain: 'selinux-python'

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
Reviewed-by: Daniel Burgener <dburgener@linux.microsoft.com>
Acked-by: Petr Lautrbach <plautrba@redhat.com>

Upstream-Status: Backport
[https://github.com/SELinuxProject/selinux/commit/344463076b2a91e1d2c7f5cc3835dc1a53a05e88]

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
 booleansPage.py          | 3 ++-
 domainsPage.py           | 3 ++-
 fcontextPage.py          | 3 ++-
 loginsPage.py            | 3 ++-
 modulesPage.py           | 3 ++-
 polgengui.py             | 3 ++-
 portsPage.py             | 3 ++-
 semanagePage.py          | 3 ++-
 statusPage.py            | 3 ++-
 system-config-selinux.py | 3 ++-
 usersPage.py             | 3 ++-
 11 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/booleansPage.py b/booleansPage.py
index 5beec58..ad11a9b 100644
--- a/booleansPage.py
+++ b/booleansPage.py
@@ -46,7 +46,8 @@ try:
         kwargs['unicode'] = True
     t = gettext.translation(PROGNAME,
                     localedir="/usr/share/locale",
-                    **kwargs)
+                    **kwargs,
+                    fallback=True)
     _ = t.gettext
 except:
     try:
diff --git a/domainsPage.py b/domainsPage.py
index e08f34b..e6eadd6 100644
--- a/domainsPage.py
+++ b/domainsPage.py
@@ -38,7 +38,8 @@ try:
         kwargs['unicode'] = True
     t = gettext.translation(PROGNAME,
                     localedir="/usr/share/locale",
-                    **kwargs)
+                    **kwargs,
+                    fallback=True)
     _ = t.gettext
 except:
     try:
diff --git a/fcontextPage.py b/fcontextPage.py
index bac2bec..767664f 100644
--- a/fcontextPage.py
+++ b/fcontextPage.py
@@ -55,7 +55,8 @@ try:
         kwargs['unicode'] = True
     t = gettext.translation(PROGNAME,
                     localedir="/usr/share/locale",
-                    **kwargs)
+                    **kwargs,
+                    fallback=True)
     _ = t.gettext
 except:
     try:
diff --git a/loginsPage.py b/loginsPage.py
index 18b93d8..7e08232 100644
--- a/loginsPage.py
+++ b/loginsPage.py
@@ -37,7 +37,8 @@ try:
         kwargs['unicode'] = True
     t = gettext.translation(PROGNAME,
                     localedir="/usr/share/locale",
-                    **kwargs)
+                    **kwargs,
+                    fallback=True)
     _ = t.gettext
 except:
     try:
diff --git a/modulesPage.py b/modulesPage.py
index c546d45..02b79f1 100644
--- a/modulesPage.py
+++ b/modulesPage.py
@@ -38,7 +38,8 @@ try:
         kwargs['unicode'] = True
     t = gettext.translation(PROGNAME,
                     localedir="/usr/share/locale",
-                    **kwargs)
+                    **kwargs,
+                    fallback=True)
     _ = t.gettext
 except:
     try:
diff --git a/polgengui.py b/polgengui.py
index a18f1cb..7a3ecd5 100644
--- a/polgengui.py
+++ b/polgengui.py
@@ -71,7 +71,8 @@ try:
         kwargs['unicode'] = True
     t = gettext.translation(PROGNAME,
                     localedir="/usr/share/locale",
-                    **kwargs)
+                    **kwargs,
+                    fallback=True)
     _ = t.gettext
 except:
     try:
diff --git a/portsPage.py b/portsPage.py
index 54aa80d..bee2bdf 100644
--- a/portsPage.py
+++ b/portsPage.py
@@ -43,7 +43,8 @@ try:
         kwargs['unicode'] = True
     t = gettext.translation(PROGNAME,
                     localedir="/usr/share/locale",
-                    **kwargs)
+                    **kwargs,
+                    fallback=True)
     _ = t.gettext
 except:
     try:
diff --git a/semanagePage.py b/semanagePage.py
index 1371d4e..efad14d 100644
--- a/semanagePage.py
+++ b/semanagePage.py
@@ -30,7 +30,8 @@ try:
         kwargs['unicode'] = True
     t = gettext.translation(PROGNAME,
                     localedir="/usr/share/locale",
-                    **kwargs)
+                    **kwargs,
+                    fallback=True)
     _ = t.gettext
 except:
     try:
diff --git a/statusPage.py b/statusPage.py
index c241ef8..832849e 100644
--- a/statusPage.py
+++ b/statusPage.py
@@ -43,7 +43,8 @@ try:
         kwargs['unicode'] = True
     t = gettext.translation(PROGNAME,
                     localedir="/usr/share/locale",
-                    **kwargs)
+                    **kwargs,
+                    fallback=True)
     _ = t.gettext
 except:
     try:
diff --git a/system-config-selinux.py b/system-config-selinux.py
index 1b460c9..9f53b7f 100644
--- a/system-config-selinux.py
+++ b/system-config-selinux.py
@@ -53,7 +53,8 @@ try:
         kwargs['unicode'] = True
     t = gettext.translation(PROGNAME,
                     localedir="/usr/share/locale",
-                    **kwargs)
+                    **kwargs,
+                    fallback=True)
     _ = t.gettext
 except:
     try:
diff --git a/usersPage.py b/usersPage.py
index d51bd96..9acd3b8 100644
--- a/usersPage.py
+++ b/usersPage.py
@@ -37,7 +37,8 @@ try:
         kwargs['unicode'] = True
     t = gettext.translation(PROGNAME,
                     localedir="/usr/share/locale",
-                    **kwargs)
+                    **kwargs,
+                    fallback=True)
     _ = t.gettext
 except:
     try:
-- 
2.25.1