gui: Make sure sepolicy calls are translated properly
PATCH 1/1 gui: Make sure sepolicy calls are translated properly
The policy is generated using sepolicy.generate, but since its translations are in a different translation domain (selinux-python as opposed to selinux-gui), the confirmation dialog is not translated.
- Add selinux-python as a fallback translation domain
- Set the whole "generate()" confirmation as translatable
- Drop "codeset" parameter since it is deprecated
--- gui/polgengui.py | 7 +++++-- python/sepolicy/sepolicy/generate.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-)
gui/polgengui.py +5 -2
@@ -69,10 +69,13 @@ try: kwargs = {} if sys.version_info < (3,): kwargs['unicode'] = True - gettext.install(PROGNAME, + t = gettext.translation(PROGNAME, localedir="/usr/share/locale", - codeset='utf-8', **kwargs) + t.install() + t.add_fallback(gettext.translation("selinux-python", + localedir="/usr/share/locale", + **kwargs)) except: try: import builtins
python/sepolicy/sepolicy/generate.py +1 -1
@@ -1372,7 +1372,7 @@ Warning %s does not exist fd.close() def generate(self, out_dir=os.getcwd()): - out = "Created the following files:\n" + out = _("Created the following files:\n") out += "%s # %s\n" % (self.write_te(out_dir), _("Type Enforcement file")) out += "%s # %s\n" % (self.write_if(out_dir), _("Interface file")) out += "%s # %s\n" % (self.write_fc(out_dir), _("File Contexts file"))
Signature · 1 line
2.35.1
Hello,
please disregard this patch. I am working on an improved solution for the issue based on module namespaces.
Sorry for the noise.
Quoted 47 lines · Vit Mojzis
The policy is generated using sepolicy.generate, but since its translations are in a different translation domain (selinux-python as opposed to selinux-gui), the confirmation dialog is not translated.
- Add selinux-python as a fallback translation domain
- Set the whole "generate()" confirmation as translatable
- Drop "codeset" parameter since it is deprecatedSigned-off-by Vit Mojzis <[email protected]>--- gui/polgengui.py | 7 +++++-- python/sepolicy/sepolicy/generate.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-)gui/polgengui.py +5
-2@@ -69,10 +69,13 @@ try: kwargs = {} if sys.version_info < (3,): kwargs['unicode'] = True - gettext.install(PROGNAME, + t = gettext.translation(PROGNAME, localedir="/usr/share/locale", - codeset='utf-8', **kwargs) + t.install() + t.add_fallback(gettext.translation("selinux-python", + localedir="/usr/share/locale", + **kwargs)) except: try: import builtinspython/sepolicy/sepolicy/generate.py +1
-1@@ -1372,7 +1372,7 @@ Warning %s does not exist fd.close() def generate(self, out_dir=os.getcwd()): - out = "Created the following files:\n" + out = _("Created the following files:\n") out += "%s # %s\n" % (self.write_te(out_dir), _("Type Enforcement file")) out += "%s # %s\n" % (self.write_if(out_dir), _("Interface file")) out += "%s # %s\n" % (self.write_fc(out_dir), _("File Contexts file"))