[PATCH] Make it possible to override translation domain in GUIObjects (#1040240)
Martin Kolman
mkolman at redhat.com
Mon Mar 31 15:21:46 UTC 2014
Some anaconda hubs and spokes are used in Initial Setup, which has
its own translation domain ("initial-setup") and needs to be able
to override the default ("anaconda") domain when a given hub/spoke
is running inside it.
Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
pyanaconda/ui/gui/__init__.py | 3 ++-
pyanaconda/ui/gui/hubs/__init__.py | 13 ++++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index a3e7558..684e656 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -78,6 +78,7 @@ class GUIObject(common.UIObject):
builderObjects = []
mainWidgetName = None
uiFile = ""
+ translationDomain = "anaconda"
screenshots_directory = "/tmp/anaconda-screenshots"
@@ -112,7 +113,7 @@ class GUIObject(common.UIObject):
self.applyOnSkip = False
self.builder = Gtk.Builder()
- self.builder.set_translation_domain("anaconda")
+ self.builder.set_translation_domain(self.translationDomain)
self._window = None
if self.builderObjects:
diff --git a/pyanaconda/ui/gui/hubs/__init__.py b/pyanaconda/ui/gui/hubs/__init__.py
index f8b016e..3bec451 100644
--- a/pyanaconda/ui/gui/hubs/__init__.py
+++ b/pyanaconda/ui/gui/hubs/__init__.py
@@ -20,6 +20,7 @@
#
import os
+import gettext
# pylint: disable-msg=E0611
from gi.repository import GLib
@@ -198,7 +199,17 @@ class Hub(GUIObject, common.Hub):
spoke.initialize()
continue
- spoke.selector = AnacondaWidgets.SpokeSelector(_(spoke.title), spoke.icon)
+ # Hubs and spokes might be used outside of Anaconda
+ # (for example in initial-setup) and individual spokes might
+ # also have different translation domains (usually spokes
+ # taken from Anaconda will have the "anaconda" domain and
+ # external spokes will have their own).
+ # Therefore we need to forward the domain of the spoke to
+ # gettext to properly translate its title.
+ spoke.selector = AnacondaWidgets.SpokeSelector(
+ gettext.ldgettext(spoke.translationDomain, spoke.title),
+ spoke.icon
+ )
# Set all selectors to insensitive before initialize runs. The call to
# _updateCompleteness later will take care of setting it straight.
--
1.8.5.3
More information about the anaconda-patches
mailing list