[PATCH 01/10] Remove the generic retranslate method from the python portion of the UI.
Chris Lumens
clumens at redhat.com
Fri Nov 30 16:28:17 UTC 2012
It doesn't work completely, and isn't needed now that we do not support changing
language from the hub via the language spoke.
---
pyanaconda/ui/common.py | 7 -------
pyanaconda/ui/gui/__init__.py | 41 -------------------------------------
pyanaconda/ui/gui/spokes/welcome.py | 8 --------
pyanaconda/ui/tui/tuiobject.py | 9 --------
4 files changed, 65 deletions(-)
diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
index 1a0a979..bcac8b4 100644
--- a/pyanaconda/ui/common.py
+++ b/pyanaconda/ui/common.py
@@ -57,13 +57,6 @@ class UIObject(object):
"""
pass
- def retranslate(self):
- """This method should be called when the current language is changed
- in order to update the UI for the new language. Since we don't get
- any toolkit help for this, it is largely a manual process.
- """
- pass
-
def refresh(self):
"""Perform whatever actions are necessary to reset the UI immediately
before it is displayed. This method is called every time a screen
diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index 52336f8..ba96523 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -302,14 +302,6 @@ class GUIObject(common.UIObject):
if self.__class__ is GUIObject:
raise TypeError("GUIObject is an abstract class")
- # This couldn't possibly be a bigger hack job. This structure holds the
- # untranslated strings out of each widget. retranslate works by taking the
- # string out of a widget, translating it, and then cramming it back into
- # the widget. When we go to change language a second time, the fetched
- # string will be the translated one. Strings in gettext are keyed on the
- # original English, so we'd be looking up translations by translations.
- self._origStrings = {}
-
self.skipTo = None
self.applyOnSkip = False
@@ -357,39 +349,6 @@ class GUIObject(common.UIObject):
_screenshotIndex += 1
- def retranslate(self):
- """This method should be called when the current language is changed
- in order to update the UI for the new language. Since we don't get
- any toolkit help for this, it is largely a manual process.
- """
- from gi.repository import AnacondaWidgets, Gtk
-
- # NOTE: If you see widgets on a screen that remain untranslated even
- # when you know there are translations, the widgets likely need to be
- # added to this dict.
- # Widget class -> (getter, setter) -or-
- # Widget class -> (setter, )
- widgetMap = { AnacondaWidgets.StandaloneWindow: ("retranslate", ),
- Gtk.Button: ("get_label", "set_label"),
- Gtk.Label: ("get_label", "set_label") }
- classes = widgetMap.keys()
-
- objs = filter(lambda obj: obj.__class__ in classes, self.builder.get_objects())
- for obj in objs:
- klass = obj.__class__
- funcs = widgetMap[klass]
-
- if len(funcs) == 1:
- getattr(obj, funcs[0])()
- else:
- # Only store the string once, so we make sure to get the original.
- if not obj in self._origStrings:
- self._origStrings[obj] = getattr(obj, funcs[0])()
-
- before = self._origStrings[obj]
- xlated = _(before)
- getattr(obj, funcs[1])(xlated)
-
@property
def window(self):
"""Return the top-level object out of the GtkBuilder representation
diff --git a/pyanaconda/ui/gui/spokes/welcome.py b/pyanaconda/ui/gui/spokes/welcome.py
index 7362a18..71093c7 100644
--- a/pyanaconda/ui/gui/spokes/welcome.py
+++ b/pyanaconda/ui/gui/spokes/welcome.py
@@ -233,10 +233,6 @@ class WelcomeLanguageSpoke(LanguageMixIn, StandaloneSpoke):
StandaloneSpoke.__init__(self, *args)
LanguageMixIn.__init__(self)
- def retranslate(self):
- StandaloneSpoke.retranslate(self)
- LanguageMixIn.retranslate(self)
-
def refresh(self):
StandaloneSpoke.refresh(self)
LanguageMixIn.refresh(self, "welcomeWindowContentBox")
@@ -283,10 +279,6 @@ class LanguageSpoke(LanguageMixIn, NormalSpoke):
LanguageMixIn.initialize(self)
NormalSpoke.initialize(self)
- def retranslate(self):
- NormalSpoke.retranslate(self)
- LanguageMixIn.retranslate(self)
-
def refresh(self):
NormalSpoke.refresh(self)
LanguageMixIn.refresh(self, "languageSpokeWindowContentBox")
diff --git a/pyanaconda/ui/tui/tuiobject.py b/pyanaconda/ui/tui/tuiobject.py
index 35c920f..42a0847 100644
--- a/pyanaconda/ui/tui/tuiobject.py
+++ b/pyanaconda/ui/tui/tuiobject.py
@@ -48,12 +48,3 @@ class TUIObject(tui.UIScreen, common.UIObject):
def refresh(self, args = None):
"""Put everything to display into self.window list."""
tui.UIScreen.refresh(self, args)
-
- def retranslate(self):
- """After language is changed, this method ensures that all the
- texts on screen are translated. It only needs to refresh the
- screen in text mode, as translation will happen automatically
- and there is no way to change labels on previously displayed content."""
-
- # redraw
- self.app.switch_screen(self)
--
1.7.11.2
More information about the anaconda-patches
mailing list