[PATCH 1/2] Mark storage errors for translations and show them translated (#877658)

Vratislav Podzimek vpodzime at redhat.com
Fri Dec 21 13:41:19 UTC 2012


On Fri, 2012-12-21 at 11:37 +0100, Vratislav Podzimek wrote:
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>  pyanaconda/storage/partitioning.py | 45 +++++++++++++++++++-------------------
>  pyanaconda/ui/gui/spokes/custom.py |  2 +-
>  2 files changed, 24 insertions(+), 23 deletions(-)
> 
> diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
> index 8e784ee..089cb8e 100644
> --- a/pyanaconda/storage/partitioning.py
> +++ b/pyanaconda/storage/partitioning.py
> @@ -37,6 +37,7 @@ from formats import getFormat
>  
>  import gettext
>  _ = lambda x: gettext.ldgettext("anaconda", x)
> +N_ = lambda x: x
>  
>  import logging
>  log = logging.getLogger("storage")
> @@ -288,7 +289,7 @@ def doAutoPartition(storage, data):
>          return
>  
>      if not storage.partitioned:
> -        raise NoDisksError("No usable disks selected")
> +        raise NoDisksError(N_("No usable disks selected"))
>  
>      disks = _getCandidateDisks(storage)
>      devs = _scheduleImplicitPartitions(storage, disks)
> @@ -296,8 +297,8 @@ def doAutoPartition(storage, data):
>      log.debug("devs: %s" % devs)
>  
>      if disks == []:
> -        raise NotEnoughFreeSpaceError("Not enough free space on disks for "
> -                                      "automatic partitioning")
> +        raise NotEnoughFreeSpaceError(N_("Not enough free space on disks for "
> +                                      "automatic partitioning"))
>  
>      _schedulePartitions(storage, disks)
>  
> @@ -626,7 +627,7 @@ def addPartition(disklabel, free, part_type, size):
>          end = disklabel.endAlignment.alignNearest(free, end)
>          log.debug("adjusted length from %d to %d" % (length, end - start + 1))
>          if start > end:
> -            raise PartitioningError("unable to allocate aligned partition")
> +            raise PartitioningError(N_("unable to allocate aligned partition"))
>  
>      new_geom = parted.Geometry(device=disklabel.partedDevice,
>                                 start=start,
> @@ -634,7 +635,7 @@ def addPartition(disklabel, free, part_type, size):
>  
>      max_length = disklabel.partedDisk.maxPartitionLength
>      if max_length and new_geom.length > max_length:
> -        raise PartitioningError("requested size exceeds maximum allowed")
> +        raise PartitioningError(N_("requested size exceeds maximum allowed"))
>  
>      # create the partition and add it to the disk
>      partition = parted.Partition(disk=disklabel.partedDisk,
> @@ -725,7 +726,7 @@ def doPartitioning(storage):
>  
>      """
>      if not hasattr(storage.platform, "diskLabelTypes"):
> -        raise StorageError("can't allocate partitions without platform data")
> +        raise StorageError(N_("can't allocate partitions without platform data"))
>  
>      disks = storage.partitioned
>      if storage.config.exclusiveDisks:
> @@ -736,7 +737,7 @@ def doPartitioning(storage):
>              disk.setup()
>          except DeviceError as (msg, name):
>              log.error("failed to set up disk %s: %s" % (name, msg))
> -            raise PartitioningError("disk %s inaccessible" % disk.name)
> +            raise PartitioningError(N_("disk %s inaccessible" % disk.name))
I've realized this wouldn't work because the subsequent call of _()
wouldn't work with the substituted values. Thus these could all be _()
instead of N_() and the second part would not be needed. I'm sending a
new version.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list