* [PATCH] gui: Make sure sepolicy calls are translated properly
@ 2022-05-03 11:42 Vit Mojzis
2022-05-04 8:11 ` Vit Mojzis
0 siblings, 1 reply; 2+ messages in thread
From: Vit Mojzis @ 2022-05-03 11:42 UTC (permalink / raw)
To: selinux
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
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
---
gui/polgengui.py | 7 +++++--
python/sepolicy/sepolicy/generate.py | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/gui/polgengui.py b/gui/polgengui.py
index 01f541ba..dcd5df47 100644
--- a/gui/polgengui.py
+++ b/gui/polgengui.py
@@ -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
diff --git a/python/sepolicy/sepolicy/generate.py b/python/sepolicy/sepolicy/generate.py
index 43180ca6..42d52109 100644
--- a/python/sepolicy/sepolicy/generate.py
+++ b/python/sepolicy/sepolicy/generate.py
@@ -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"))
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gui: Make sure sepolicy calls are translated properly
2022-05-03 11:42 [PATCH] gui: Make sure sepolicy calls are translated properly Vit Mojzis
@ 2022-05-04 8:11 ` Vit Mojzis
0 siblings, 0 replies; 2+ messages in thread
From: Vit Mojzis @ 2022-05-04 8:11 UTC (permalink / raw)
To: selinux
Hello,
please disregard this patch. I am working on an improved solution for
the issue based on module namespaces.
Sorry for the noise.
On 5/3/22 13:42, Vit Mojzis wrote:
> 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
>
> Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
> ---
> gui/polgengui.py | 7 +++++--
> python/sepolicy/sepolicy/generate.py | 2 +-
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/gui/polgengui.py b/gui/polgengui.py
> index 01f541ba..dcd5df47 100644
> --- a/gui/polgengui.py
> +++ b/gui/polgengui.py
> @@ -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
> diff --git a/python/sepolicy/sepolicy/generate.py b/python/sepolicy/sepolicy/generate.py
> index 43180ca6..42d52109 100644
> --- a/python/sepolicy/sepolicy/generate.py
> +++ b/python/sepolicy/sepolicy/generate.py
> @@ -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"))
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-04 8:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-03 11:42 [PATCH] gui: Make sure sepolicy calls are translated properly Vit Mojzis
2022-05-04 8:11 ` Vit Mojzis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.