[PATCH] Clean up translation placeholders (#890157)
Brian C. Lane
bcl at redhat.com
Sat Aug 17 01:28:12 UTC 2013
From: "Brian C. Lane" <bcl at redhat.com>
---
anaconda | 25 ++++++++++--------
pyanaconda/bootloader.py | 43 ++++++++++++++++---------------
pyanaconda/ui/gui/spokes/custom.py | 26 ++++++++++---------
pyanaconda/ui/gui/spokes/lib/accordion.py | 4 ++-
pyanaconda/ui/gui/spokes/lib/cart.py | 6 ++---
pyanaconda/ui/gui/spokes/lib/resize.py | 6 ++---
pyanaconda/ui/gui/spokes/storage.py | 8 +++---
pyanaconda/ui/gui/spokes/welcome.glade | 2 +-
pyanaconda/ui/gui/spokes/welcome.py | 2 +-
9 files changed, 66 insertions(+), 56 deletions(-)
diff --git a/anaconda b/anaconda
index be0a5d8..c4f5502 100755
--- a/anaconda
+++ b/anaconda
@@ -360,10 +360,10 @@ def gtk_warning(title, reason):
# pylint: disable-msg=W0621
def check_memory(anaconda, options, display_mode=None):
- reason_strict = _("%s requires %s MB of memory to install, but you only have "
- "%s MB on this machine.\n")
- reason_graphical = _("The %s graphical installer requires %s MB of memory, but "
- "you only have %s MB.")
+ reason_strict = _("%(product_name)s requires %(needed_ram)s MB of memory to "
+ "install, but you only have %(total_ram)s MB on this machine.\n")
+ reason_graphical = _("The %(product_name)s graphical installer requires %(needed_ram)s "
+ "MB of memory, but you only have %(total_ram)s MB.")
reboot_extra = _('\n'
'Press <return> to reboot your system.\n')
@@ -391,35 +391,38 @@ def check_memory(anaconda, options, display_mode=None):
log.warning("CHECK_MEMORY DISABLED")
return
+ reason_args = {"product_name" : product.productName,
+ "needed_ram" : needed_ram,
+ "total_ram" : total_ram }
if needed_ram > total_ram:
from snack import SnackScreen, ButtonChoiceWindow
if options.liveinst:
- stdoutLog.warning(reason % (product.productName, needed_ram, total_ram))
- gtk_warning(livecd_title, reason % (product.productName, needed_ram, total_ram))
+ stdoutLog.warning(reason % reason_args)
+ gtk_warning(livecd_title, reason % reason_args)
else:
reason += reboot_extra
screen = SnackScreen()
ButtonChoiceWindow(screen, _('Fatal Error'),
- reason % (product.productName, needed_ram, total_ram),
+ reason % reason_args,
buttons = (_("OK"),))
screen.finish()
sys.exit(1)
# override display mode if machine cannot nicely run X
if display_mode not in ('t', 'c', 's') and not flags.usevnc:
- needed_ram = graphical_ram
+ reason_args["needed_ram"] = graphical_ram
reason = reason_graphical
if needed_ram > total_ram:
if options.liveinst:
reason += livecd_extra
- stdoutLog.warning(reason % (product.productName, needed_ram, total_ram))
+ stdoutLog.warning(reason % reason_args)
title = livecd_title
- gtk_warning(title, reason % (product.productName, needed_ram, total_ram))
+ gtk_warning(title, reason % reason_args)
sys.exit(1)
else:
reason += nolivecd_extra
- stdoutLog.warning(reason % (product.productName, needed_ram, total_ram))
+ stdoutLog.warning(reason % reason_args)
anaconda.displayMode = 't'
time.sleep(2)
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 10bfaa9..9a0fe6f 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -387,9 +387,9 @@ class BootLoader(object):
if raid_levels and device.level not in raid_levels:
levels_str = ",".join("RAID%d" % l for l in raid_levels)
- self.errors.append(_("RAID sets that contain '%s' must have one "
- "of the following raid levels: %s.")
- % (desc, levels_str))
+ self.errors.append(_("RAID sets that contain '%(desc)s' must have one "
+ "of the following raid levels: %(raid_level)s.")
+ % {"desc" : desc, "raid_level" : levels_str})
ret = False
# new arrays will be created with an appropriate metadata format
@@ -403,10 +403,10 @@ class BootLoader(object):
if member_types:
for member in device.devices:
if not self._device_type_match(member, member_types):
- self.errors.append(_("RAID sets that contain '%s' must "
+ self.errors.append(_("RAID sets that contain '%(desc)s' must "
"have one of the following device "
- "types: %s.")
- % (desc, ",".join(member_types)))
+ "types: %(types)s.")
+ % {"desc" : desc, "types" : ",".join(member_types)})
ret = False
log.debug("_is_valid_md(%s) returning %s" % (device.name,ret))
@@ -419,9 +419,9 @@ class BootLoader(object):
label_type = getattr(disk.format, "labelType", None)
if not label_type or label_type not in self.disklabel_types:
types_str = ",".join(disklabel_types)
- self.errors.append(_("%s must have one of the following "
- "disklabel types: %s.")
- % (device.name, types_str))
+ self.errors.append(_("%(name)s must have one of the following "
+ "disklabel types: %(types)s.")
+ % {"name" : device.name, "types" : types_str})
ret = False
log.debug("_is_valid_disklabel(%s) returning %s" % (device.name,ret))
@@ -431,14 +431,14 @@ class BootLoader(object):
desc=""):
ret = True
if format_types and device.format.type not in format_types:
- self.errors.append(_("%s cannot be of type %s.")
- % (desc, device.format.type))
+ self.errors.append(_("%(desc)s cannot be of type %(type)s.")
+ % {"desc" : desc, "type" : device.format.type})
ret = False
if mountpoints and hasattr(device.format, "mountpoint") \
and device.format.mountpoint not in mountpoints:
- self.errors.append(_("%s must be mounted on one of %s.")
- % (desc, ", ".join(mountpoints)))
+ self.errors.append(_("%(desc)s must be mounted on one of %(mountpoints)s.")
+ % {"desc" : desc, "mountpoints" : ", ".join(mountpoints)})
ret = False
log.debug("_is_valid_format(%s) returning %s" % (device.name,ret))
@@ -449,13 +449,14 @@ class BootLoader(object):
msg = None
errors = []
if device.format.minSize and device.format.maxSize:
- msg = (_("%s must be between %d and %d MB in size")
- % (desc, device.format.minSize, device.format.maxSize))
+ msg = (_("%(desc)s must be between %(min)d and %(max)d MB in size")
+ % {"desc" : desc, "min" : device.format.minSize,
+ "max" : device.format.maxSize})
if device.format.minSize and device.size < device.format.minSize:
if msg is None:
- errors.append(_("%s must not be smaller than %dMB.")
- % (desc, device.format.minSize))
+ errors.append(_("%(desc)s must not be smaller than %(min)dMB.")
+ % {"desc" : desc, "min" : device.format.minSize})
else:
errors.append(msg)
@@ -463,8 +464,8 @@ class BootLoader(object):
if device.format.maxSize and device.size > device.format.maxSize:
if msg is None:
- errors.append(_("%s must not be larger than %dMB.")
- % (desc, device.format.maxSize))
+ errors.append(_("%(desc)s must not be larger than %(max)dMB.")
+ % {"desc" : desc, "max" : device.format.maxSize})
elif msg not in errors:
# don't add the same error string twice
errors.append(msg)
@@ -671,8 +672,8 @@ class BootLoader(object):
valid = False
if not self._device_type_match(device, self.stage2_device_types):
- self.errors.append(_("%s cannot be of type %s")
- % (self.stage2_description, device.type))
+ self.errors.append(_("%(desc)s cannot be of type %(type)s")
+ % {"desc" : self.stage2_description, "type" : device.type})
valid = False
if not self._is_valid_disklabel(device,
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index b3e0ce8..b1e17ab 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -91,7 +91,7 @@ NOTEBOOK_LUKS_PAGE = 2
NOTEBOOK_UNEDITABLE_PAGE = 3
NOTEBOOK_INCOMPLETE_PAGE = 4
-new_install_name = N_("New %s %s Installation")
+new_install_name = N_("New %(name)s %(version)s Installation")
new_container_text = N_("Create a new %(container_type)s ...")
container_dialog_title = N_("CONFIGURE %(container_type)s")
container_dialog_text = N_("Please create a name for this %(container_type)s "
@@ -107,9 +107,9 @@ empty_mountpoint_msg = N_("Please enter a valid mountpoint.")
invalid_mountpoint_msg = N_("That mount point is invalid. Try something else?")
mountpoint_in_use_msg = N_("That mount point is already in use. Try something else?")
-raid_level_not_enough_disks_msg = N_("The RAID level you have selected (%s) "
- "requires more disks (%d) than you "
- "currently have selected (%d).")
+raid_level_not_enough_disks_msg = N_("The RAID level you have selected (%(level)s) "
+ "requires more disks (%(min)d) than you "
+ "currently have selected (%(count)d).")
empty_name_msg = N_("Please enter a valid name.")
invalid_name_msg = N_("That name is invalid. Try something else?")
@@ -528,7 +528,9 @@ class ContainerDialog(GUIObject):
min_disks = mdraid.get_raid_min_members(md_level)
if len(paths) < min_disks:
self._error = (_(raid_level_not_enough_disks_msg)
- % (raid_level, min_disks, len(paths)))
+ % {"level" : raid_level,
+ "min" : min_disks,
+ "count" : len(paths)})
self._error_label.set_text(self._error)
self.window.show_all()
return
@@ -885,7 +887,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
@property
def translated_new_install_name(self):
- return _(new_install_name) % (productName, productVersion)
+ return _(new_install_name) % {"name" : productName, "version" : productVersion}
@property
def _current_page(self):
@@ -953,7 +955,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
self._accordion.addPage(page, cb=self.on_page_clicked)
self._partitionsNotebook.set_current_page(NOTEBOOK_LABEL_PAGE)
- self._whenCreateLabel.set_text(self._when_create_text % (productName, productVersion))
+ self._whenCreateLabel.set_text(self._when_create_text % {"name" : productName, "version" : productVersion})
else:
swaps = [d for d in new_devices if d.format.type == "swap"]
mounts = dict((d.format.mountpoint, d) for d in new_devices
@@ -1236,8 +1238,8 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
% _(DEVICE_TEXT_PARTITION))
elif device_type != DEVICE_TYPE_PARTITION and \
fs_type_short in partition_only_format_types:
- error = (_("%s must be on a device of type %s")
- % (fs_type, _(DEVICE_TEXT_PARTITION)))
+ error = (_("%(fs)s must be on a device of type %(type)s")
+ % {"fs" : fs_type, "type" : _(DEVICE_TEXT_PARTITION)})
elif mountpoint and encrypted and mountpoint.startswith("/boot"):
error = _("%s cannot be encrypted") % mountpoint
elif encrypted and fs_type_short in partition_only_format_types:
@@ -2038,9 +2040,9 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
log.error("factoryDevice failed w/ old container: %s" % e2)
else:
type_str = device_text_map[device_type]
- self.set_info(_("Added new %s to existing "
- "container %s.")
- % (type_str, container.name))
+ self.set_info(_("Added new %(type)s to existing "
+ "container %(name)s.")
+ % {"type" : type_str, "name" : container.name})
self.window.show_all()
e = None
diff --git a/pyanaconda/ui/gui/spokes/lib/accordion.py b/pyanaconda/ui/gui/spokes/lib/accordion.py
index 2c44245..c7959cb 100644
--- a/pyanaconda/ui/gui/spokes/lib/accordion.py
+++ b/pyanaconda/ui/gui/spokes/lib/accordion.py
@@ -257,7 +257,9 @@ class CreateNewPage(Page):
self._createBox.set_column_spacing(6)
self._createBox.set_margin_left(16)
- label = Gtk.Label(_("You haven't created any mount points for your %s %s installation yet. You can:") % (productName, productVersion))
+ label = Gtk.Label(_("You haven't created any mount points for your "
+ "%(product)s %(version)s installation yet. "
+ "You can:") % {"product" : productName, "version" : productVersion})
label.set_line_wrap(True)
label.set_alignment(0, 0.5)
self._createBox.attach(label, 0, 0, 2, 1)
diff --git a/pyanaconda/ui/gui/spokes/lib/cart.py b/pyanaconda/ui/gui/spokes/lib/cart.py
index 45fef95..b3a2ca5 100644
--- a/pyanaconda/ui/gui/spokes/lib/cart.py
+++ b/pyanaconda/ui/gui/spokes/lib/cart.py
@@ -130,11 +130,11 @@ class SelectedDisksDialog(GUIObject):
size = str(Size(bytes=long(size))).upper()
free = str(Size(bytes=long(free))).upper()
- text = P_("<b>%d disk; %s capacity; %s free space</b> "
+ text = P_("<b>%(count)d disk; %(size)s capacity; %(free)s free space</b> "
"(unpartitioned and in filesystems)",
- "<b>%d disks; %s capacity; %s free space</b> "
+ "<b>%(count)d disks; %(size)s capacity; %(free)s free space</b> "
"(unpartitioned and in filesystems)",
- count) % (count, size, free)
+ count) % {"count" : count, "size" : size, "free" : free}
self._summary_label.set_markup(text)
# signal handlers
diff --git a/pyanaconda/ui/gui/spokes/lib/resize.py b/pyanaconda/ui/gui/spokes/lib/resize.py
index b3bf272..aaf987c 100644
--- a/pyanaconda/ui/gui/spokes/lib/resize.py
+++ b/pyanaconda/ui/gui/spokes/lib/resize.py
@@ -209,9 +209,9 @@ class ResizeDialog(GUIObject):
def _update_labels(self, nDisks=None, totalReclaimable=None, selectedReclaimable=None):
if nDisks is not None and totalReclaimable is not None:
- text = P_("<b>%s disk; %s reclaimable space</b> (in filesystems)",
- "<b>%s disks; %s reclaimable space</b> (in filesystems)",
- nDisks) % (nDisks, size_str(totalReclaimable))
+ text = P_("<b>%(count)s disk; %(size)s reclaimable space</b> (in filesystems)",
+ "<b>%(count)s disks; %(size)s reclaimable space</b> (in filesystems)",
+ nDisks) % {"count" : nDisks, "size" : size_str(totalReclaimable)}
self._reclaimable_label.set_markup(text)
if selectedReclaimable is not None:
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index 2cd1ab3..57b7009 100644
--- a/pyanaconda/ui/gui/spokes/storage.py
+++ b/pyanaconda/ui/gui/spokes/storage.py
@@ -699,9 +699,11 @@ class StorageSpoke(NormalSpoke, StorageChecker):
free += free_space[disk.name][0]
count += 1
- summary = (P_("%d disk selected; %s capacity; %s free",
- "%d disks selected; %s capacity; %s free",
- count) % (count, str(Size(spec="%s MB" % capacity)), free))
+ summary = (P_("%(count)d disk selected; %(capacity)s capacity; %(free)s free",
+ "%(count)d disks selected; %(capacity)s capacity; %(free)s free",
+ count) % {"count" : count,
+ "capacity" : str(Size(spec="%s MB" % capacity)),
+ "free" : free})
summary_label = self.builder.get_object("summary_label")
summary_label.set_text(summary)
summary_label.set_sensitive(count > 0)
diff --git a/pyanaconda/ui/gui/spokes/welcome.glade b/pyanaconda/ui/gui/spokes/welcome.glade
index 820ce49..67bb449 100644
--- a/pyanaconda/ui/gui/spokes/welcome.glade
+++ b/pyanaconda/ui/gui/spokes/welcome.glade
@@ -374,7 +374,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="ypad">6</property>
- <property name="label" translatable="yes">WELCOME TO %s %s.</property>
+ <property name="label" translatable="yes">WELCOME TO %(name)s %(version)s.</property>
<attributes>
<attribute name="font-desc" value="Cantarell Bold 16"/>
</attributes>
diff --git a/pyanaconda/ui/gui/spokes/welcome.py b/pyanaconda/ui/gui/spokes/welcome.py
index 84de5ae..b2fc293 100644
--- a/pyanaconda/ui/gui/spokes/welcome.py
+++ b/pyanaconda/ui/gui/spokes/welcome.py
@@ -211,7 +211,7 @@ class WelcomeLanguageSpoke(StandaloneSpoke):
before = self._origStrings[welcomeLabel]
# pylint: disable-msg=E1103
- xlated = _(before) % (productName.upper(), productVersion)
+ xlated = _(before) % {"name" : productName.upper(), "version" : productVersion}
welcomeLabel.set_label(xlated)
# And of course, don't forget the underlying window.
--
1.8.3.1
More information about the anaconda-patches
mailing list