170 lines
6.5 KiB
Diff
170 lines
6.5 KiB
Diff
From 67c8d8d452c44519ba78fc0f605d6754afc4fe0b Mon Sep 17 00:00:00 2001
|
|
From: Vit Mojzis <vmojzis@redhat.com>
|
|
Date: Tue, 5 Sep 2017 13:33:52 +0200
|
|
Subject: [PATCH 12/19] framework: Fix semi-translated messages
|
|
|
|
Gettext domains were hardcoded in some modules (pointing to translations
|
|
for setroubleshoot plugins) which caused semi-translated messages.
|
|
Remove hardcoded gettext domain and use value from config file instead.
|
|
|
|
Note:
|
|
gettext.install sets the "_" function into global builtins namespace,
|
|
as opposed "manually" setting "_" with gettext.translation(...).gettext,
|
|
which only affects given module. Therefore in some cases both methods
|
|
were left in use.
|
|
|
|
Fixes:
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1332126
|
|
|
|
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
|
|
---
|
|
framework/src/setroubleshoot/Plugin.py | 10 +++++++---
|
|
framework/src/setroubleshoot/browser.py | 7 +++++--
|
|
framework/src/setroubleshoot/errcode.py | 11 ++++++++---
|
|
framework/src/setroubleshoot/server.py | 7 +++++--
|
|
framework/src/setroubleshoot/signature.py | 17 ++++++++++-------
|
|
6 files changed, 41 insertions(+), 20 deletions(-)
|
|
|
|
diff --git a/framework/src/setroubleshoot/Plugin.py b/framework/src/setroubleshoot/Plugin.py
|
|
index 8ec8deb..c67b6ad 100644
|
|
--- a/framework/src/setroubleshoot/Plugin.py
|
|
+++ b/framework/src/setroubleshoot/Plugin.py
|
|
@@ -20,12 +20,16 @@
|
|
#
|
|
|
|
import gettext
|
|
-translation=gettext.translation('setroubleshoot-plugins', fallback=True)
|
|
+from setroubleshoot.config import parse_config_setting, get_config
|
|
+
|
|
+translation=gettext.translation(domain = get_config('general', 'i18n_text_domain'),
|
|
+ localedir = get_config('general', 'i18n_locale_dir'),
|
|
+ fallback = True)
|
|
|
|
try:
|
|
- _ = translation.ugettext # This raises exception in Python3, succ. in Py2
|
|
+ _ = translation.ugettext # Unicode version of gettext for Py2
|
|
except AttributeError:
|
|
- _ = translation.gettext # Python3
|
|
+ _ = translation.gettext # Python3 (uses unicode by default)
|
|
|
|
from setroubleshoot.signature import *
|
|
from setroubleshoot.util import *
|
|
diff --git a/framework/src/setroubleshoot/browser.py b/framework/src/setroubleshoot/browser.py
|
|
index dbfccb0..84aef6d 100644
|
|
--- a/framework/src/setroubleshoot/browser.py
|
|
+++ b/framework/src/setroubleshoot/browser.py
|
|
@@ -29,15 +29,18 @@ from setroubleshoot.config import parse_config_setting, get_config
|
|
import six
|
|
import sys
|
|
domain = get_config('general', 'i18n_text_domain')
|
|
+localedir = get_config('general', 'i18n_locale_dir')
|
|
|
|
kwargs = {}
|
|
if sys.version_info < (3,):
|
|
kwargs['unicode'] = True
|
|
gettext.install(domain = domain,
|
|
- localedir = get_config('general', 'i18n_locale_dir'),
|
|
+ localedir = localedir,
|
|
**kwargs)
|
|
|
|
-translation=gettext.translation(domain, fallback=True)
|
|
+translation=gettext.translation(domain = domain,
|
|
+ localedir = localedir,
|
|
+ fallback=True)
|
|
|
|
rows = 1
|
|
|
|
diff --git a/framework/src/setroubleshoot/errcode.py b/framework/src/setroubleshoot/errcode.py
|
|
index b1e6da8..804aaa1 100644
|
|
--- a/framework/src/setroubleshoot/errcode.py
|
|
+++ b/framework/src/setroubleshoot/errcode.py
|
|
@@ -17,12 +17,17 @@
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
#
|
|
import gettext
|
|
-translation=gettext.translation('setroubleshoot-plugins', fallback=True)
|
|
+from setroubleshoot.config import parse_config_setting, get_config
|
|
+
|
|
+translation=gettext.translation(domain = get_config('general', 'i18n_text_domain'),
|
|
+ localedir = get_config('general', 'i18n_locale_dir'),
|
|
+ fallback = True)
|
|
|
|
try:
|
|
- _ = translation.ugettext # This raises exception in Python3, succ. in Py2
|
|
+ _ = translation.ugettext # Unicode version of gettext for Py2
|
|
except AttributeError:
|
|
- _ = translation.gettext # Python3
|
|
+ _ = translation.gettext # Python3 (uses unicode by default)
|
|
+
|
|
|
|
__all__ = [
|
|
'ProgramError',
|
|
diff --git a/framework/src/setroubleshoot/server.py b/framework/src/setroubleshoot/server.py
|
|
index f336f1a..7093bff 100755
|
|
--- a/framework/src/setroubleshoot/server.py
|
|
+++ b/framework/src/setroubleshoot/server.py
|
|
@@ -48,14 +48,17 @@ import systemd.journal
|
|
from setroubleshoot.config import parse_config_setting, get_config
|
|
|
|
domain = get_config('general', 'i18n_text_domain')
|
|
+localedir = get_config('general', 'i18n_locale_dir')
|
|
kwargs = {}
|
|
if sys.version_info < (3,):
|
|
kwargs['unicode'] = True
|
|
gettext.install(domain = domain,
|
|
- localedir = get_config('general', 'i18n_locale_dir'),
|
|
+ localedir = localedir,
|
|
**kwargs)
|
|
|
|
-translation=gettext.translation(domain, fallback=True)
|
|
+translation=gettext.translation(domain = domain,
|
|
+ localedir = localedir,
|
|
+ fallback = True)
|
|
|
|
try:
|
|
_ = translation.ugettext # This raises exception in Python3, succ. in Py2
|
|
diff --git a/framework/src/setroubleshoot/signature.py b/framework/src/setroubleshoot/signature.py
|
|
index b3ef158..27f5e57 100755
|
|
--- a/framework/src/setroubleshoot/signature.py
|
|
+++ b/framework/src/setroubleshoot/signature.py
|
|
@@ -24,15 +24,20 @@ from __future__ import print_function
|
|
import six
|
|
import syslog
|
|
from subprocess import *
|
|
-import gettext
|
|
from six.moves import range
|
|
from functools import cmp_to_key
|
|
-translation=gettext.translation('setroubleshoot-plugins', fallback=True)
|
|
+import gettext
|
|
+from setroubleshoot.config import parse_config_setting, get_config
|
|
+
|
|
+translation=gettext.translation(domain = get_config('general', 'i18n_text_domain'),
|
|
+ localedir = get_config('general', 'i18n_locale_dir'),
|
|
+ fallback = True)
|
|
|
|
try:
|
|
- _ = translation.ugettext # This raises exception in Python3, succ. in Py2
|
|
+ _ = translation.ugettext # Unicode version of gettext for Py2
|
|
except AttributeError:
|
|
- _ = translation.gettext # Python3
|
|
+ _ = translation.gettext # Python3 (uses unicode by default)
|
|
+
|
|
|
|
__all__ = [
|
|
'SignatureMatch',
|
|
@@ -56,10 +61,8 @@ __all__ = [
|
|
]
|
|
|
|
if __name__ == "__main__":
|
|
- import gettext
|
|
- from setroubleshoot.config import parse_config_setting, get_config
|
|
gettext.install(domain = get_config('general', 'i18n_text_domain'),
|
|
- localedir = get_config('general', 'i18n_locale_dir'))
|
|
+ localedir = get_config('general', 'i18n_locale_dir'))
|
|
|
|
from gettext import ngettext as P_
|
|
from setroubleshoot.config import get_config
|
|
--
|
|
2.14.1
|
|
|