[PATCH 06/10] Substitute on new_install_name when it's needed, not at the top of custom.py.

Chris Lumens clumens at redhat.com
Fri Nov 30 16:28:22 UTC 2012


What we've got now is a string names new_install_name with the product and
version substituted into it, then that string being looked up for translation.
There's no string that matches, of course, so the new install header on the
LHS is not being displayed translated.
---
 pyanaconda/ui/gui/spokes/custom.py | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index eeacf8e..a487531 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -91,7 +91,7 @@ NOTEBOOK_DETAILS_PAGE = 1
 NOTEBOOK_LUKS_PAGE = 2
 NOTEBOOK_UNEDITABLE_PAGE = 3
 
-new_install_name = N_("New %s %s Installation") % (productName, productVersion)
+new_install_name = N_("New %s %s Installation")
 unrecoverable_error_msg = N_("Storage configuration reset due to unrecoverable "
                              "error. Click for details.")
 device_configuration_error_msg = N_("Device reconfiguration failed. Click for "
@@ -570,6 +570,10 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
 
         self._updateSpaceDisplay()
 
+    @property
+    def translated_new_install_name(self):
+        return _(new_install_name) % (productName, productVersion)
+
     def _do_refresh(self):
         # block mountpoint selector signal handler for now
         self._initialized = False
@@ -617,7 +621,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         # ensures it's only added once.
         if not new_devices:
             page = CreateNewPage(self.on_create_clicked)
-            page.pageTitle = _(new_install_name)
+            page.pageTitle = self.translated_new_install_name
             self._accordion.addPage(page, cb=self.on_page_clicked)
 
             if page.pageTitle not in page_order:
@@ -635,7 +639,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
                 if device in self.bootLoaderDevices:
                     mounts[device.format.type] = device
 
-            new_root = Root(mounts=mounts, swaps=swaps, name=_(new_install_name))
+            new_root = Root(mounts=mounts, swaps=swaps, name=self.translated_new_install_name)
             ui_roots.insert(0, new_root)
 
         # Add in all the existing (or autopart-created) operating systems.
@@ -644,7 +648,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
             # Also, only include devices in an old page if the format is intact.
             if not [d for d in root.swaps + root.mounts.values()
                         if d in self._devices and d.disks and
-                           (root.name == _(new_install_name) or d.format.exists)]:
+                           (root.name == self.translated_new_install_name or d.format.exists)]:
                 continue
 
             page = Page()
@@ -653,7 +657,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
             for (mountpoint, device) in root.mounts.iteritems():
                 if device not in self._devices or \
                    not device.disks or \
-                   (root.name != _(new_install_name) and not device.format.exists):
+                   (root.name != self.translated_new_install_name and not device.format.exists):
                     continue
 
                 selector = page.addDevice(self._mountpointName(mountpoint) or device.format.name, Size(spec="%f MB" % device.size), mountpoint, self.on_selector_clicked)
@@ -662,7 +666,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
 
             for device in root.swaps:
                 if device not in self._devices or \
-                   (root.name != _(new_install_name) and not device.format.exists):
+                   (root.name != self.translated_new_install_name and not device.format.exists):
                     continue
 
                 selector = page.addDevice("Swap",
@@ -731,15 +735,15 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
 
     def add_new_selector(self, device):
         """ Add an entry for device to the new install Page. """
-        page = self._accordion._find_by_title(_(new_install_name)).get_child()
+        page = self._accordion._find_by_title(self.translated_new_install_name).get_child()
         devices = [device]
         if not hasattr(page, "_members"):
             # remove the CreateNewPage and replace it with a regular Page
-            expander = self._accordion._find_by_title(_(new_install_name))
+            expander = self._accordion._find_by_title(self.translated_new_install_name)
             expander.remove(expander.get_child())
 
             page = Page()
-            page.pageTitle = _(new_install_name)
+            page.pageTitle = self.translated_new_install_name
             expander.add(page)
 
             # pull in all the existing swap devices
@@ -765,7 +769,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
     def _update_btrfs_selectors(self):
         """ Update all btrfs selectors' size properties. """
         # we're only updating selectors in the new root. problem?
-        page = self._accordion._find_by_title(_(new_install_name)).get_child()
+        page = self._accordion._find_by_title(self.translated_new_install_name).get_child()
         if not hasattr(page, "_members"):
             return
 
@@ -1135,7 +1139,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
                         for page in self._accordion.allPages:
                             for _selector in getattr(page, "_members", []):
                                 if _selector._device in (device, old_device):
-                                    if page.pageTitle == _(new_install_name):
+                                    if page.pageTitle == self.translated_new_install_name:
                                         new_selector = _selector
                                         continue
 
@@ -1720,7 +1724,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
 
         log.debug("removing device '%s' from page %s" % (device, root_name))
 
-        if root_name == _(new_install_name):
+        if root_name == self.translated_new_install_name:
             if device.exists:
                 # This is an existing device that was added to the new page.
                 # All we want to do is revert any changes to the device and
-- 
1.7.11.2



More information about the anaconda-patches mailing list