--- pilgrim.py.prepatch-translation	2007-08-05 19:32:33.000000000 +0200
+++ pilgrim.py	2007-08-05 19:44:53.000000000 +0200
@@ -34,6 +34,10 @@
 import pykickstart.parser
 import pykickstart.version

+# Translation
+from rhpl.translate import _, N_, getDefaultLangs
+import rhpl.translate as translate
+
 class MountError(Exception):
     def __init__(self, msg):
         Exception.__init__(self, msg)
@@ -60,7 +64,7 @@
                 os.makedirs(self.dest)
             rc = subprocess.call(["/bin/mount", "--bind", self.src, self.dest])
             if rc != 0:
-                raise MountError("Bind-mounting '%s' to '%s' failed" % (self.src, self.dest))
+                raise MountError(_("Bind-mounting '%s' to '%s' failed") % (self.src, self.dest))
             self.mounted = True

     def umount(self):
@@ -108,7 +112,7 @@

         rc = subprocess.call(["/sbin/losetup", "-f", self.lofile])
         if rc != 0:
-            raise MountError("Failed to allocate loop device for '%s'" % self.lofile)
+            raise MountError(_("Failed to allocate loop device for '%s'") % self.lofile)

         # succeeded; figure out which loopdevice we're using
         buf = subprocess.Popen(["/sbin/losetup", "-a"],
@@ -123,7 +127,7 @@
                 break

         if not self.loopdev:
-            raise MountError("Failed to find loop device associated with '%s' from '/sbin/losetup -a'" % self.lofile)
+            raise MountError(_("Failed to find loop device associated with '%s' from '/sbin/losetup -a'") % self.lofile)

         self.losetup = True

@@ -143,7 +147,7 @@

         rc = subprocess.call(args)
         if rc != 0:
-            raise MountError("Failed to mount '%s' to '%s'" % (self.loopdev, self.mountdir))
+            raise MountError(_("Failed to mount '%s' to '%s'") % (self.loopdev, self.mountdir))

         self.mounted = True

@@ -170,7 +174,7 @@
                               "-m", "1", "-b", "4096", self.lofile,
                               "%d" % ( self.size *  1024L * 1024L / 4096L )])
         if rc != 0:
-            raise MountError("Error creating ext3 filesystem")
+            raise MountError(_("Error creating ext3 filesystem"))
         rc = subprocess.call(["/sbin/tune2fs", "-c0", "-i0", "-Odir_index",
                               "-ouser_xattr,acl", self.lofile])

@@ -219,7 +223,7 @@
         try:
             self.install(pattern = pkg)
         except yum.Errors.InstallError, e:
-            raise InstallationError("Failed to find package '%s' : %s" % (pkg, e))
+            raise InstallationError(_("Failed to find package '%s' : %s") % (pkg, e))

     def deselectPackage(self, pkg):
         """Deselect package.  Can be specified as name.arch or name*"""
@@ -236,13 +240,13 @@
         if len(txmbrs) > 0:
             map(lambda x: self.tsInfo.remove(x.pkgtup), txmbrs)
         else:
-            print >> sys.stderr, "No such package %s to remove" %(pkg,)
+            print >> sys.stderr, _("No such package %s to remove") %(pkg,)

     def selectGroup(self, grp, include = pykickstart.parser.GROUP_DEFAULT):
         try:
             yum.YumBase.selectGroup(self, grp)
         except (yum.Errors.InstallError, yum.Errors.GroupsError), e:
-            raise InstallationError("Failed to find group '%s' : %s" % (grp, e))
+            raise InstallationError(_("Failed to find group '%s' : %s") % (grp, e))
         if include == pykickstart.parser.GROUP_REQUIRED:
             map(lambda p: self.deselectPackage(p), grp.default_packages.keys())
         elif include == pykickstart.parser.GROUP_ALL:
@@ -276,9 +280,9 @@
         try:
             (res, resmsg) = self.buildTransaction()
         except yum.Errors.RepoError, e:
-            raise InstallationError("Unable to download from repo : %s" %(e,))
+            raise InstallationError(_("Unable to download from repo : %s") %(e,))
         if res != 2 and False:
-            raise InstallationError("Failed to build transaction : %s" % str.join("\n", resmsg))
+            raise InstallationError(_("Failed to build transaction : %s") % str.join("\n", resmsg))

         dlpkgs = map(lambda x: x.po, filter(lambda txmbr: txmbr.ts_state in ("i", "u"), self.tsInfo.getMembers()))
         self.downloadPkgs(dlpkgs)
@@ -321,9 +325,9 @@
             try:
                 self.ksparser.readKickstart(kscfg)
             except IOError, (err, msg):
-                raise InstallationError("Failed to read kickstart file '%s' : %s" % (kscfg, msg))
+                raise InstallationError(_("Failed to read kickstart file '%s' : %s") % (kscfg, msg))
             except pykickstart.errors.KickstartError, e:
-                raise InstallationError("Failed to parse kickstart file '%s' : %s" % (kscfg, e))
+                raise InstallationError(_("Failed to parse kickstart file '%s' : %s") % (kscfg, e))

             for repo in self.ksparser.handler.repo.repoList:
                 already_given = False
@@ -342,15 +346,15 @@
             self.epackages.extend(self.ksparser.handler.packages.excludedList)

         if not self.packages and not self.groups:
-            raise InstallationError("No packages or groups specified")
+            raise InstallationError(_("No packages or groups specified"))

         if not self.repos:
-            raise InstallationError("No repositories specified")
+            raise InstallationError(_("No repositories specified"))

         # more sanity checks
         if self.ksparser.handler.selinux.selinux and not \
                os.path.exists("/selinux/enforce"):
-            raise InstallationError("SELinux requested but not enabled on host system")
+            raise InstallationError(_("SELinux requested but not enabled on host system"))

     def base_on_iso(self, base_on):
         """helper function to extract ext3 file system from a live CD ISO"""
@@ -365,20 +369,20 @@
             try:
                 isoloop.mount()
             except MountError, e:
-                raise InstallationError("Failed to loopback mount '%s' : %s" % (base_on, e))
+                raise InstallationError(_("Failed to loopback mount '%s' : %s") % (base_on, e))

             if not os.path.exists(squashloop.lofile):
-                raise InstallationError("'%s' is not a valid live CD ISO : squashfs.img doesn't exist" % base_on)
+                raise InstallationError(_("'%s' is not a valid live CD ISO : squashfs.img doesn't exist") % base_on)

             try:
                 squashloop.mount()
             except MountError, e:
-                raise InstallationError("Failed to loopback mount squashfs.img from '%s' : %s" % (base_on, e))
+                raise InstallationError(_("Failed to loopback mount squashfs.img from '%s' : %s") % (base_on, e))

             os_image = self.build_dir + "/base_on_squashfs/os.img"

             if not os.path.exists(os_image):
-                raise InstallationError("'%s' is not a valid live CD ISO : os.img doesn't exist" % base_on)
+                raise InstallationError(_("'%s' is not a valid live CD ISO : os.img doesn't exist") % base_on)

             shutil.copyfile(os_image, self.build_dir + "/data/os.img")
         finally:
@@ -445,7 +449,7 @@
         try:
             self.instloop.mount()
         except MountError, e:
-            raise InstallationError("Failed to loopback mount '%s' : %s" % (self.instloop.lofile, e))
+            raise InstallationError(_("Failed to loopback mount '%s' : %s") % (self.instloop.lofile, e))

         if not base_on:
             # create a few directories needed if it's a new image
@@ -506,7 +510,7 @@
             (xxbsize, xxfrsize, xxblocks, xxbfree,
              xxbavail, xxfiles, xxffree, xxfavail,
              xxflag, xxnamemax) = os.statvfs(self.build_dir + "/install_root")
-            print >> sys.stderr, "Installation target uncompressed data size is %d MB" % ( ( xxfrsize * xxblocks - xxbsize * xxbfree ) / ( 1024L * 1024L ) )
+            print >> sys.stderr, _("Installation target uncompressed data size is %d MB") % ( ( xxfrsize * xxblocks - xxbsize * xxbfree ) / ( 1024L * 1024L ) )
             self.instloop.cleanup()
             self.instloop = None

@@ -532,7 +536,7 @@

             self.ayum.runInstall()
         except yum.Errors.RepoError, e:
-            raise InstallationError("Unable to download from repo : %s" %(e,))
+            raise InstallationError(_("Unable to download from repo : %s") %(e,))
         finally:
             self.ayum.closeRpmDB()

@@ -654,12 +658,12 @@

         for network in self.ksparser.handler.network.network:
             if not network.device:
-                raise InstallationError("No --device specified with network kickstart command")
+                raise InstallationError(_("No --device specified with network kickstart command"))

             if network.onboot and network.bootProto.lower() != "dhcp" and \
                not (network.ip and network.netmask):
-                raise InstallationError("No IP address and/or netmask specified with static " +
-                                        "configuration for '%s'" % network.device)
+                raise InstallationError(_("No IP address and/or netmask specified with static " +
+                                        "configuration for '%s'") % network.device)

             self.writeNetworkIfCfg(instroot, network)
             self.writeNetworkKey(instroot, network)
@@ -768,7 +772,7 @@
                         self.ksparser.handler.scripts):
             # we can only safely run scripts in the chroot
             if not s.inChroot:
-                print >> sys.stderr, "Not running script outside of chroot"
+                print >> sys.stderr, _("Not running script outside of chroot")
                 continue

             (fd, path) = tempfile.mkstemp("", "ks-script-", "%s/tmp" %(instroot,))
@@ -781,7 +785,7 @@
                                 preexec_fn = self.run_in_root)
             except OSError, (err, msg):
                 os.unlink(path)
-                raise InstallationError("Failed to execute %%post script with '%s' : %s" % (s.interp, msg))
+                raise InstallationError(_("Failed to execute %%post script with '%s' : %s") % (s.interp, msg))
             os.unlink(path)

     def get_kernel_version(self):
@@ -796,15 +800,15 @@
             kernels = os.listdir(modules_dir)

         if not kernels:
-            raise InstallationError("No kernels installed: /lib/modules is empty")
+            raise InstallationError(_("No kernels installed: /lib/modules is empty"))

         return kernels[0]

     def createInitramfs(self):
         # Create initramfs
         if not os.path.isfile("/usr/lib/livecd-creator/mayflower"):
-            raise InstallationError("livecd-creator not correctly installed : "+
-                                    "/usr/lib/livecd-creator/mayflower not found")
+            raise InstallationError(_("livecd-creator not correctly installed : " +
+                                    "/usr/lib/livecd-creator/mayflower not found"))
         shutil.copy("/usr/lib/livecd-creator/mayflower",
                         "%s/install_root/sbin/mayflower" %(self.build_dir,))
         # modules needed for booting (this is butt ugly and we need to retrieve this from elsewhere, e.g. the kernel)
@@ -873,7 +877,7 @@
                 syslinuxMenu=m
                 break
         if syslinuxMenu is None:
-            raise InstallationError("syslinux not installed : no suitable *menu.c32 found")
+            raise InstallationError(_("syslinux not installed : no suitable *menu.c32 found"))

         isXen = False
         xen = glob.glob("%s/install_root/boot/xen.gz-*" %(self.build_dir,))
@@ -885,7 +889,7 @@
         for p in syslinuxfiles:
             path = "%s/install_root/usr/lib/syslinux/%s" % (self.build_dir, p)
             if not os.path.isfile(path):
-                raise InstallationError("syslinux not installed : %s not found" % path)
+                raise InstallationError(_("syslinux not installed : %s not found") % path)

             shutil.copy(path, "%s/out/isolinux/%s" % (self.build_dir, p))

@@ -954,7 +958,7 @@
         try:
             self.configureSystem()
         except Exception, e: #FIXME: we should be a little bit more fine-grained
-            raise InstallationError("Error configuring live image: %s" %(e,))
+            raise InstallationError(_("Error configuring live image: %s") %(e,))
         self.configureNetwork()
         self.relabelSystem()
         if not self.skip_prelink:
@@ -976,7 +980,7 @@
             subprocess.call(["/usr/lib/anaconda-runtime/implantisomd5",
                              "%s.iso" %(self.fs_label,)])
         else:
-            print >> sys.stderr, "anaconda-runtime not installed; not setting up mediacheck"
+            print >> sys.stderr, _("anaconda-runtime not installed; not setting up mediacheck")

     def createSquashFS(self):
         """create compressed squashfs file system"""
@@ -1029,7 +1033,7 @@

         os.close(FNULL)

-        print >> sys.stderr, "Installation target minimized to %dK" % (size_top * 4)
+        print >> sys.stderr, _("Installation target minimized to %dK") % (size_top * 4)

         # truncate the unused excess portion of the sparse file
         fd = os.open("%s/data/os.img" %(self.build_dir,), os.O_WRONLY )
@@ -1064,29 +1068,29 @@
                       [--yumcache]
                       [--tmpdir=<tmpdir>]

- --help              : Print usage and exit
- --config            : Path to kickstart config file
- --repo              : Add / override yum repository
- --package           : Include this package
- --exclude-package   : Exclude this package
- --base-on           : Add packages to an existing live CD iso9660 image
- --fslabel           : File system label (default: livecd-YYYYMMDD-HHMI)
- --skip-compression  : Don't compress the image
- --prelink           : Prelink the image
- --uncompressed-size : Size of uncompressed fs in MB (default: 4096)
- --ignore-deleted    : Don't run resize2fs to clean up wasted blocks
- --builddir          : Use this build directory
- --installroot       : Use this directory as installroot
- --yumcache          : Use this yum cache directory
- --shell             : Start a shell in the chroot for post-configuration
- --tmpdir            : Temporary directory to use (default: /var/tmp)
+ --help              : """ + _("Print usage and exit") + """
+ --config            : """ + _("Path to kickstart config file") + """
+ --repo              : """ + _("Add / override yum repository") + """
+ --package           : """ + _("Include this package") + """
+ --exclude-package   : """ + _("Exclude this package") + """
+ --base-on           : """ + _("Add packages to an existing live CD iso9660 image") + """
+ --fslabel           : """ + _("File system label (default: livecd-YYYYMMDD-HHMI)") + """
+ --skip-compression  : """ + _("Don't compress the image") + """
+ --prelink           : """ + _("Prelink the image") + """
+ --uncompressed-size : """ + _("Size of uncompressed fs in MB (default: 4096)") + """
+ --ignore-deleted    : """ + _("Don't run resize2fs to clean up wasted blocks") + """
+ --builddir          : """ + _("Use this build directory") + """
+ --installroot       : """ + _("Use this directory as installroot") + """
+ --yumcache          : """ + _("Use this yum cache directory") + """
+ --shell             : """ + _("Start a shell in the chroot for post-configuration") + """
+ --tmpdir            : """ + _("Temporary directory to use (default: /var/tmp)") + """

- Examples:
+ """ + _("Examples:") + """

-  Create minimal live cd:
+  """ + _("Create minimal live cd:") + """
   # livecd-creator --config=/usr/share/livecd-tools/livecd-fedora-minimal.ks

-  Create minimal live cd and use local package repositories:
+  """ + _("Create minimal live cd and use local package repositories:") + """
   # livecd-creator --config=/usr/share/livecd-tools/livecd-fedora-minimal.ks \\
                    --repo=a-dev,file:///home/user/core/RPMS             \\
                    --repo=a-extras-dev,file:///home/user/extras/RPMS
@@ -1154,13 +1158,13 @@
         if o in ("-c", "--config"):
             options.kscfg = a
             if not os.path.isfile(options.kscfg):
-                raise Usage("Kickstart config '%s' does not exist" % options.kscfg)
+                raise Usage(_("Kickstart config '%s' does not exist") % options.kscfg)
             continue
         if o in ("-r", "--repo"):
             (name, url) = a.split(",")
             for (n, u) in options.repos:
                 if n == name:
-                    raise Usage("Repo name '%s' is already in use" % n)
+                    raise Usage(_("Repo name '%s' is already in use") % n)
             options.repos.append((name, url))
             continue
         if o in ("-p", "--package"):
@@ -1175,12 +1179,12 @@
         if o in ("-f", "--fslabel"):
             options.fs_label = a
             if len(options.fs_label) > 32:
-                raise Usage("CD labels are limited to 32 characters")
+                raise Usage(_("CD labels are limited to 32 characters"))
             continue
         if o in ("-b", "--base-on"):
             options.base_on = a
             if not os.path.isfile(options.base_on):
-                raise Usage("Live CD ISO '%s' does not exist" % options.base_on)
+                raise Usage(_("Live CD ISO '%s' does not exist") % options.base_on)
             continue
         if o in ("-t", "--tmpdir"):
             options.tmpdir = a
@@ -1194,13 +1198,13 @@
         if o in ("-y", "--yumcache"):
             options.yum_cache = a
             continue
-        raise Usage("Unknown option %s" % o)
+        raise Usage(_("Unknown option %s") % o)

     if not options.kscfg and not (options.packages or options.groups):
-        raise Usage("No packages or groups specified")
+        raise Usage(_("No packages or groups specified"))

     if not options.kscfg and not options.repos:
-        raise Usage("No repositories specified")
+        raise Usage(_("No repositories specified"))

     return options

@@ -1220,7 +1224,7 @@
         return ret

     if os.geteuid () != 0:
-        print >> sys.stderr, "You must run livecd-creator as root"
+        print >> sys.stderr, _("You must run livecd-creator as root")
         return 1

     target = InstallationTarget(options.repos,
@@ -1240,7 +1244,7 @@
         target.install()

         if options.give_shell:
-            print "Launching shell. Exit to continue."
+            print _("Launching shell. Exit to continue.")
             print "----------------------------------"
             target.launchShell()

@@ -1251,7 +1255,7 @@

         target.package()
     except InstallationError, e:
-        print >> sys.stderr, "Error creating Live CD : %s" % e
+        print >> sys.stderr, _("Error creating Live CD : %s") % e
         target.teardown()
         return 1
     target.teardown()
