[PATCH] Improve the translatability of strings with more than one format specifier.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 pyanaconda/installinterfacebase.py |   12 +++++-------
 pyanaconda/iw/filter_gui.py        |    2 +-
 pyanaconda/iw/partition_gui.py     |    4 ++--
 pyanaconda/iw/upgrade_swap_gui.py  |    7 ++++---
 pyanaconda/platform.py             |    4 ++--
 pyanaconda/rescue.py               |    3 +--
 pyanaconda/storage/__init__.py     |   23 ++++++++++++-----------
 pyanaconda/storage/devices.py      |    6 +++---
 pyanaconda/text.py                 |    2 +-
 pyanaconda/textw/constants_text.py |    2 +-
 pyanaconda/textw/upgrade_text.py   |    7 ++++---
 11 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/pyanaconda/installinterfacebase.py b/pyanaconda/installinterfacebase.py
index 4f55103..898c863 100644
--- a/pyanaconda/installinterfacebase.py
+++ b/pyanaconda/installinterfacebase.py
@@ -69,13 +69,11 @@ class InstallInterfaceBase(object):
             self._warnedUnusedRaidMembers.extend(unusedRaidMembers)
             unusedRaidMembers.sort()
             self.messageWindow(_("Warning"),
-                P_("Disk %s contains BIOS RAID metadata, but is not part of "
-                   "any recognized BIOS RAID sets. Ignoring disk %s.",
-                   "Disks %s contain BIOS RAID metadata, but are not part of "
-                   "any recognized BIOS RAID sets. Ignoring disks %s.",
-                   len(unusedRaidMembers)) %
-                   (", ".join(unusedRaidMembers),
-                    ", ".join(unusedRaidMembers)),
+                P_("Disk %(unusedRaidMems)s contains BIOS RAID metadata, but is not part of "
+                   "any recognized BIOS RAID sets. Ignoring disk %(unusedRaidMems)s.",
+                   "Disks %(unusedRaidMems)s contain BIOS RAID metadata, but are not part of "
+                   "any recognized BIOS RAID sets. Ignoring disks %(unusedRaidMems)s.",
+                   len(unusedRaidMembers)) % {"unusedRaidMems": ", ".join(unusedRaidMembers)},
                 custom_icon="warning")
 
     def resetInitializeDiskQuestion(self):
diff --git a/pyanaconda/iw/filter_gui.py b/pyanaconda/iw/filter_gui.py
index a0d99a2..69098c3 100644
--- a/pyanaconda/iw/filter_gui.py
+++ b/pyanaconda/iw/filter_gui.py
@@ -148,7 +148,7 @@ class Callbacks(object):
         global selectedDevices, totalDevices
         global selectedSize, totalSize
 
-        self.sizeLabel.set_markup(_("Selected devices: %s (%s MB) out of %s (%s MB).") % (selectedDevices, selectedSize, totalDevices, totalSize))
+        self.sizeLabel.set_markup(_("Selected devices: %(selectedDevices)s (%(selectedSize)s MB) out of %(totalDevices)s (%(totalSize)s MB).") % {"selectedDevices": selectedDevices, "selectedSize": selectedSize, "totalDevices": totalDevices, "totalSize": totalSize})
 
     def visible(self, model, iter, view):
         # Most basic visibility function - does the model say this row
diff --git a/pyanaconda/iw/partition_gui.py b/pyanaconda/iw/partition_gui.py
index 2a2ce97..6d539fb 100644
--- a/pyanaconda/iw/partition_gui.py
+++ b/pyanaconda/iw/partition_gui.py
@@ -447,7 +447,7 @@ class LVMStripeGraph(StripeGraph):
 
     def _createStripe(self, vg):
         # Create the stripe
-        vgtext = _("LVM Volume Group %s (%-0.f MB)") % (vg.name, vg.size)
+        vgtext = _("LVM Volume Group %(vgName)s (%(vgSize)-0.f MB)") % {"vgName", vg.name, "vgSize": vg.size}
         stripe = Stripe(self.getCanvas(), vgtext, self.dcCB, obj = vg)
 
         # Create the slices.
@@ -513,7 +513,7 @@ class MDRaidArrayStripeGraph(StripeGraph):
             self.setDisplayed(md)
 
     def _createStripe(self, md):
-        mdtext = _("MD RAID ARRAY %s (%-0.f MB)") % (md.path, md.size)
+        mdtext = _("MD RAID ARRAY %(mdPath)s (%(mdSize)-0.f MB)") % {"mdPath": md.path, "mdSize": md.size}
         stripe = Stripe(self.getCanvas(), mdtext, self.dcCB, obj = md)
 
         # Since we can't really create subslices with md devices we will only
diff --git a/pyanaconda/iw/upgrade_swap_gui.py b/pyanaconda/iw/upgrade_swap_gui.py
index ddb8735..a998154 100644
--- a/pyanaconda/iw/upgrade_swap_gui.py
+++ b/pyanaconda/iw/upgrade_swap_gui.py
@@ -89,10 +89,11 @@ class UpgradeSwapWindow (InstallWindow):
         box = gtk.VBox (False, 5)
         box.set_border_width (5)
 
-        label = gtk.Label(_("You currently have %dMB of swap configured, which "
-                            "is less than the recommended miminum of %sMB.  You "
+        label = gtk.Label(_("You currently have %(swapAmount)dMB of swap configured, which "
+                            "is less than the recommended miminum of %(swapSuggestion)sMB.  You "
                             "may optionally create more swap space on one of "
-                            "your file systems now.") % (iutil.swapAmount()/1024, iutil.swapSuggestion()[0]/1024))
+                            "your file systems now.") % {"swapAmount": iutil.swapAmount()/1024,
+                                                         "swapSuggestion": iutil.swapSuggestion()[0]/1024})
 
         label.set_alignment (0.5, 0.0)
         label.set_line_wrap (True)
diff --git a/pyanaconda/platform.py b/pyanaconda/platform.py
index 3942887..9e636df 100644
--- a/pyanaconda/platform.py
+++ b/pyanaconda/platform.py
@@ -258,8 +258,8 @@ class EFI(Platform):
             labelType = self.diskLabelType(partedDisk.device.type)
             # Allow using gpt with x86, but not msdos with EFI
             if partedDisk.type != labelType and partedDisk.type != "gpt":
-                errors.append(_("%s must have a %s disk label.")
-                              % (p.disk.name, labelType.upper()))
+                errors.append(_("%(disk)s must have a %(labelType)s disk label.")
+                               % {"disk": p.disk.name, "labelType": labelType.upper()})
 
         return errors
 
diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index f6e55dc..245a597 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -455,8 +455,7 @@ def runRescue(anaconda):
                 ButtonChoiceWindow(screen, _("Rescue"),
                     _("An error occurred trying to mount some or all of your "
                       "system. Some of it may be mounted under %s.\n\n"
-                      "Press <return> to get a shell. %s")
-                      % (anaconda.rootPath, msg),
+                      "Press <return> to get a shell.") % anaconda.rootPath + msg,
                       [_("OK")] )
     else:
         if anaconda.ksdata and \
diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index 6c8b47d..472627c 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -1131,15 +1131,15 @@ class Storage(object):
         for (mount, device) in filesystems.items():
             problem = filesystems[mount].checkSize()
             if problem < 0:
-                errors.append(_("Your %s partition is too small for %s formatting "
-                                "(allowable size is %d MB to %d MB)")
-                              % (mount, problem, device.format.name,
-                                 device.minSize, device.maxSize))
+                errors.append(_("Your %(mount)s partition is too small for %(format)s formatting "
+                                "(allowable size is %(minSize)d MB to %(maxSize)d MB)")
+                              % {"mount": mount, "format": device.format.name,
+                                 "minSize": device.minSize, "maxSize": device.maxSize})
             elif problem > 0:
-                errors.append(_("Your %s partition is too large for %s formatting "
-                                "(allowable size is %d MB to %d MB)")
-                              % (mount, problem, device.format.name,
-                                 device.minSize, device.maxSize))
+                errors.append(_("Your %(mount)s partition is too large for %(format)s formatting "
+                                "(allowable size is %(minSize)d MB to %(maxSize)d MB)")
+                              % {"mount":mount, "format": device.format.name,
+                                 "minSize": device.minSize, "maxSize": device.maxSize})
 
         usb_disks = []
         firewire_disks = []
@@ -1180,9 +1180,10 @@ class Storage(object):
 
             if installed < required:
                 errors.append(_("You have not specified a swap partition.  "
-                                "%s MB of memory is required to continue installation "
-                                "without a swap partition, but you only have %s MB.")
-                              % (int(required.convertTo(spec="MB")), int(installed.convertTo(spec="MB"))))
+                                "%(requiredMem)s MB of memory is required to continue installation "
+                                "without a swap partition, but you only have %(installedMem)s MB.")
+                              % {"requiredMem": int(required.convertTo(spec="MB")),
+                                 "installedMem": int(installed.convertTo(spec="MB"))})
             else:
                 warnings.append(_("You have not specified a swap partition.  "
                                   "Although not strictly required in all cases, "
diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index 97606f8..36145a3 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -2637,10 +2637,10 @@ class MDRaidArrayDevice(StorageDevice):
         # For new arrays check if we have enough members
         if (not exists and parents and
                 len(parents) < mdraid.get_raid_min_members(self.level)):
-            raise ValueError, P_("A RAID%d set requires at least %d member",
-                                 "A RAID%d set requires at least %d members",
+            raise ValueError, P_("A RAID%(raidLevel)d set requires at least %(minMembers)d member",
+                                 "A RAID%(raidLevel)d set requires at least %(minMembers)d members",
                                  mdraid.get_raid_min_members(self.level)) % \
-                                 (self.level, mdraid.get_raid_min_members(self.level))
+                                 {"raidLevel": self.level, "minMembers": mdraid.get_raid_min_members(self.level)}
 
         self.uuid = uuid
         self._totalDevices = numeric_type(totalDevices)
diff --git a/pyanaconda/text.py b/pyanaconda/text.py
index a5dd1a5..89c858d 100644
--- a/pyanaconda/text.py
+++ b/pyanaconda/text.py
@@ -260,7 +260,7 @@ class InstallInterface(InstallInterfaceBase):
 
     def reinitializeWindow(self, title, path, size, description):
         grid = GridForm(self.screen, title, 1, 3)
-        text = TEXT_REINITIALIZE % (description, size, path)
+        text = TEXT_REINITIALIZE % {"description": description, "size": size, "devicePath": path}
         grid.add(TextboxReflowed(70, text), 0, 0)
 
         all_devices_cb = Checkbox(TEXT_REINITIALIZE_ALL, isOn=False)
diff --git a/pyanaconda/textw/constants_text.py b/pyanaconda/textw/constants_text.py
index d11b684..2563ffa 100644
--- a/pyanaconda/textw/constants_text.py
+++ b/pyanaconda/textw/constants_text.py
@@ -74,7 +74,7 @@ TEXT_F12_CHECK = "F12"
 TEXT_REINITIALIZE = _(
 """This storage device may contain data:
 
-%s, %s MB, %s
+%(description)s, %(size)s MB, %(devicePath)s
 
 We could not detect partitions or filesystems on this device. This could be \
 because the device is blank, unpartitioned, or virtual. If not, there may be \
diff --git a/pyanaconda/textw/upgrade_text.py b/pyanaconda/textw/upgrade_text.py
index 4b3152d..75f5f45 100644
--- a/pyanaconda/textw/upgrade_text.py
+++ b/pyanaconda/textw/upgrade_text.py
@@ -109,10 +109,11 @@ class UpgradeSwapWindow:
 
         ramDetected = iutil.memInstalled()/1024
 
-        text = _("You currently have %dMB of swap configured, which "
-                 "is less than the recommended miminum of %sMB.  You "
+        text = _("You currently have %(swapAmount)dMB of swap configured, which "
+                 "is less than the recommended miminum of %(swapSuggestion)sMB.  You "
                  "may optionally create more swap space on one of "
-                 "your file systems now.") % (iutil.swapAmount()/1024, iutil.swapSuggestion()[0]/1024)
+                 "your file systems now.") % {"swapAmount": iutil.swapAmount()/1024,
+                                              "swapSuggestion": iutil.swapSuggestion()[0]/1024}
 
 	tb = TextboxReflowed(60, text)
 	amount = Entry(10, scroll = 0)
-- 
1.7.4.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux