diff options
author | Preston Cody <codeman@gentoo.org> | 2008-05-26 02:53:12 +0000 |
---|---|---|
committer | Preston Cody <codeman@gentoo.org> | 2008-05-26 02:53:12 +0000 |
commit | 30070d726eeb5255abea5da387a78a27db214a36 (patch) | |
tree | bef024eea24be7e9eb8456b34825962a70784881 | |
parent | committing changes to gtkfe in stages. (diff) | |
download | gli-30070d726eeb5255abea5da387a78a27db214a36.tar.gz gli-30070d726eeb5255abea5da387a78a27db214a36.tar.bz2 gli-30070d726eeb5255abea5da387a78a27db214a36.zip |
adding internalization support written by
Jesus Rivero (Neurogeek)
basically sets everything in gettext.
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/gli/trunk@1908 f8877401-5920-0410-a79b-8e2d7e04ca0d
-rw-r--r-- | src/GLIArchitectureTemplate.py | 100 |
1 files changed, 55 insertions, 45 deletions
diff --git a/src/GLIArchitectureTemplate.py b/src/GLIArchitectureTemplate.py index 6a7b855..57a4a1f 100644 --- a/src/GLIArchitectureTemplate.py +++ b/src/GLIArchitectureTemplate.py @@ -18,11 +18,21 @@ import GLIUtility, GLILogger, os, string, sys, shutil, re, time import GLIPortage from GLIException import * import Partitioning +import gettext MEGABYTE = 1024 * 1024 LOGFILE = '/var/log/install.log' COMPILE_LOGFILE = '/tmp/compile_output.log' +#Start Gettext Support +try: + gettext.install('gli-gtk', './languages') + translator = gettext.translation('gli-gtk', './languages') + _ = translator.gettext +except: + _ = gettext.gettext +#End Gettext Support + class ArchitectureTemplate: ## # Initialization of the ArchitectureTemplate. Called from some other arch template. @@ -63,37 +73,37 @@ class ArchitectureTemplate: self._architecture_name = "generic" self._install_steps = { - 'do_recommended_partitioning': "Automatically partition the drive", - 'mount_local_partitions': "Mount local partitions", - 'mount_network_shares': "Mount network (NFS) shares", - 'unpack_stage_tarball': "Unpack stage tarball", - 'update_config_files': "Updating config files", - 'configure_make_conf': "Configure /etc/make.conf", - 'prepare_chroot': "Preparing chroot", - 'install_portage_tree': "Syncing the Portage tree", - 'stage1': "Performing bootstrap", - 'stage2': "Performing 'emerge system'", - 'set_root_password': "Set the root password", - 'set_timezone': "Setting timezone", - 'emerge_kernel_sources': "Emerge kernel sources", - 'build_kernel': "Building kernel", - 'install_distcc': "Install distcc", - 'install_mta': "Installing MTA", - 'install_logging_daemon': "Installing system logger", - 'install_cron_daemon': "Installing Cron daemon", - 'install_filesystem_tools': "Installing filesystem tools", - 'setup_network_post': "Configuring post-install networking", - 'install_bootloader': "Configuring and installing bootloader", - 'setup_and_run_bootloader': "Setting up and running bootloader", + 'do_recommended_partitioning': _("Automatically partition the drive"), + 'mount_local_partitions': _("Mount local partitions"), + 'mount_network_shares': _("Mount network (NFS) shares"), + 'unpack_stage_tarball': _("Unpack stage tarball"), + 'update_config_files': _("Updating config files"), + 'configure_make_conf': _("Configure /etc/make.conf"), + 'prepare_chroot': _("Preparing chroot"), + 'install_portage_tree': _("Syncing the Portage tree"), + 'stage1': _("Performing bootstrap"), + 'stage2': _("Performing 'emerge system'"), + 'set_root_password': _("Set the root password"), + 'set_timezone': _("Setting timezone"), + 'emerge_kernel_sources': _("Emerge kernel sources"), + 'build_kernel': _("Building kernel"), + 'install_distcc': _("Install distcc"), + 'install_mta': _("Installing MTA"), + 'install_logging_daemon': _("Installing system logger"), + 'install_cron_daemon': _("Installing Cron daemon"), + 'install_filesystem_tools': _("Installing filesystem tools"), + 'setup_network_post': _("Configuring post-install networking"), + 'install_bootloader': _("Configuring and installing bootloader"), + 'setup_and_run_bootloader': _("Setting up and running bootloader"), # 'update_config_files': "Re-Updating config files", #second run. - 'set_users': "Add additional users.", - 'install_packages': "Installing additional packages.", + 'set_users': _("Add additional users."), + 'install_packages': _("Installing additional packages."), # services for startup need to come after installing extra packages # otherwise some of the scripts will not exist. - 'set_services': "Setting up services for startup", - 'run_post_install_script': "Running custom post-install script", - 'finishing_cleanup': "Cleanup and unmounting local filesystems.", - 'install_failed_cleanup': "Cleaning up after a failed install" + 'set_services': _("Setting up services for startup"), + 'run_post_install_script': _("Running custom post-install script"), + 'finishing_cleanup': _("Cleanup and unmounting local filesystems."), + 'install_failed_cleanup' : _("Cleaning up after a failed install") } ## @@ -291,7 +301,7 @@ class ArchitectureTemplate: mounts = self._install_profile.get_mounts() mount_progress = 1 - self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), "Generating mount list")) + self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), _("Generating mount list"))) parts_to_mount = {} for mount in mounts: Partitioning.wait_for_device_node(mount['devnode']) @@ -300,7 +310,7 @@ class ArchitectureTemplate: partition_type = mount['type'] if partition_type in ("linux-swap", "swap"): mount_progress += 1 - self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), "Activating swap on " + mount['devnode'])) + self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), _("Activating swap on ") + mount['devnode'])) ret = GLIUtility.spawn("swapon " + mount['devnode']) if not GLIUtility.exitsuccess(ret): self._logger.log("ERROR! : Could not activate swap (" + mount['devnode'] + ")!") @@ -334,7 +344,7 @@ class ArchitectureTemplate: partition_type = parts_to_mount[mountpoint][1] partition = parts_to_mount[mountpoint][2] mount_progress += 1 - self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), "Mounting %s at %s" % (partition, mountpoint))) + self.notify_frontend("progress", (float(mount_progress) / (len(mounts)+1), _("Mounting %(partition)s at %(mountpoint)s") % {'partition' : partition, 'mountpoint' : mountpoint})) if not GLIUtility.is_file(self._chroot_dir + mountpoint): if self._debug: self._logger.log("DEBUG: making mountpoint: "+mountpoint) exitstatus = GLIUtility.spawn("mkdir -p " + self._chroot_dir + mountpoint) @@ -413,9 +423,9 @@ class ArchitectureTemplate: syspkglen = len(systempkgs) for i, pkg in enumerate(systempkgs): pkg = pkg.strip() - self.notify_frontend("progress", (float(i) / (syspkglen+1), "Copying " + pkg + " (" + str(i+1) + "/" + str(syspkglen) + ")")) + self.notify_frontend("progress", (float(i) / (syspkglen+1), _("Copying ") + pkg + " (" + str(i+1) + "/" + str(syspkglen) + ")")) self._portage.copy_pkg_to_chroot(pkg, True, ignore_missing=True) - self.notify_frontend("progress", (float(syspkglen) / (syspkglen+1), "Finishing")) + self.notify_frontend("progress", (float(syspkglen) / (syspkglen+1), _("Finishing"))) GLIUtility.spawn("cp /etc/make.conf " + self._chroot_dir + "/etc/make.conf") # Remove warning from make.conf GLIUtility.spawn("sed -i '/^##/d' " + self._chroot_dir + "/etc/make.conf") @@ -456,7 +466,7 @@ class ArchitectureTemplate: script.close() GLIUtility.spawn("chmod 755 /tmp/extrastuff.sh && /tmp/extrastuff.sh", chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True) GLIUtility.spawn("rm -rf /var/tmp/portage/* /usr/portage /tmp/*", chroot=self._chroot_dir) - self.notify_frontend("progress", (1, "Done")) + self.notify_frontend("progress", (1, _("Done"))) if not GLIUtility.is_file("/etc/make.conf"): raise GLIException("CreateStage3Error", "fatal", "unpack_stage_tarball", "Something went wrong during stage3 generation, /etc/make.conf doesn't exist on the new system! ") self._logger.log("Stage3 was generated successfully") @@ -671,17 +681,17 @@ class ArchitectureTemplate: # Special case, livecd kernel elif kernel_pkg == "livecd-kernel": if self._debug: self._logger.log("DEBUG: starting livecd-kernel setup") - self.notify_frontend("progress", (0, "Determining files to copy")) + self.notify_frontend("progress", (0, _("Determining files to copy"))) GLIUtility.spawn(r"find /var/db/pkg -type f -name CONTENTS | xargs awk '/^obj \/lib\/modules\// { print $2; }' > /tmp/kernel_modules") files = GLIUtility.spawn('ls -1 --color=no /boot/System* /boot/kernel* /boot/initr* $(for i in $(find "/lib/modules/" -type f); do grep --quiet "^${i}$" /tmp/kernel_modules || echo ${i}; done); rm /tmp/kernel_modules 2>/dev/null', return_output=True)[1].strip().split("\n") if not files: raise GLIException("LiveCDKernelError", 'fatal','emerge_kernel_sources', "Could not determine files to copy for livecd-kernel") - self.notify_frontend("progress", (0.2, "Copying kernel, initramfs, and modules")) + self.notify_frontend("progress", (0.2, _("Copying kernel, initramfs, and modules"))) if not GLIUtility.exitsuccess(GLIUtility.spawn("cp -p --parents %s %s/" % (" ".join(files), self._chroot_dir), logfile=self._compile_logfile, append_log=True)): raise GLIException("LiveCDKernelError", 'fatal','emerge_kernel_sources', "Could not copy kernel, initramfs, or modules") - self.notify_frontend("progress", (0.4, "Generating module dependencies")) + self.notify_frontend("progress", (0.4, _("Generating module dependencies"))) GLIUtility.spawn("depmod -a", logfile=self._compile_logfile, append_log=True) - self.notify_frontend("progress", (0.6, "Gathering portage configuration")) + self.notify_frontend("progress", (0.6, _("Gathering portage configuration"))) portage_info = {} for line in GLIUtility.spawn(r"emerge --info 2>/dev/null | grep '^[A-Z0-9_]\+=' | sed -e 's:\" \([A-Z]\):\"\n\1:g'", chroot=self._chroot_dir, return_output=True)[1].strip().split("\n"): parts = line.split("=", 1) @@ -711,7 +721,7 @@ class ArchitectureTemplate: 'SLOT': "0", 'USE': arch } - self.notify_frontend("progress", (0.8, "Creating VDB entry for livecd-kernel")) + self.notify_frontend("progress", (0.8, _("Creating VDB entry for livecd-kernel"))) vdbdir = self._chroot_dir + "/var/db/pkg/sys-kernel/livecd-kernel-1" os.mkdir(vdbdir) for tmpfile in values: @@ -726,7 +736,7 @@ class ArchitectureTemplate: counter_f.write(str(counter)) counter_f.close() GLIUtility.spawn("echo | bzip2 > %s/environment.bz2" % vdbdir) - self.notify_frontend("progress", (1, "Done copying livecd-kernel to chroot")) + self.notify_frontend("progress", (1, _("Done copying livecd-kernel to chroot"))) if self._install_profile.get_kernel_bootsplash(): self._logger.log("Bootsplash enabled for livecd-kernel...this is currently broken, so we're skipping the package install") @@ -860,7 +870,7 @@ class ArchitectureTemplate: genkernel_options = genkernel_options + " --no-gensplash" # Run genkernel in chroot #print "genkernel all " + genkernel_options - self.notify_frontend("progress", (0, "Compiling kernel. Please be patient!")) + self.notify_frontend("progress", (0, _("Compiling kernel. Please be patient!"))) if self._debug: self._logger.log("DEBUG: build_kernel(): running: genkernel all " + genkernel_options + " in chroot.") exitstatus = GLIUtility.spawn("genkernel all " + genkernel_options, chroot=self._chroot_dir, display_on_tty8=True, logfile=self._compile_logfile, append_log=True) if not GLIUtility.exitsuccess(exitstatus): @@ -1418,9 +1428,9 @@ class ArchitectureTemplate: steps = len(self._mounted_devices) + len(self._swap_devices) + 2 if self._debug: self._logger.log("DEBUG: install_failed_cleanup(): running: mv /tmp/compile_output.log /tmp/compile_output.log.failed") - self.notify_frontend("progress", (float(1) / (steps), "Moving compile output logfile")) + self.notify_frontend("progress", (float(1) / (steps), _("Moving compile output logfile"))) GLIUtility.spawn("cp " + self._compile_logfile + " " + self._compile_logfile + ".failed && rm " + self._compile_logfile) - self.notify_frontend("progress", (float(2) / (steps), "Moving install logfile")) + self.notify_frontend("progress", (float(2) / (steps), _("Moving install logfile"))) GLIUtility.spawn("mv " + LOGFILE + " " + LOGFILE + ".failed") cur_step = 2 @@ -1432,7 +1442,7 @@ class ArchitectureTemplate: mounted_devices.reverse() for mount in mounted_devices: cur_step += 1 - self.notify_frontend("progress", (float(cur_step) / (steps), "Unmounting " + mount)) + self.notify_frontend("progress", (float(cur_step) / (steps), _("Unmounting ") + mount)) if self._debug: self._logger.log("DEBUG: install_failed_cleanup(): running: umount -l " + mount) ret = GLIUtility.spawn("umount -l " + self._chroot_dir + mount) if not GLIUtility.exitsuccess(ret): @@ -1442,7 +1452,7 @@ class ArchitectureTemplate: # we need to find the swap devices for swap_device in self._swap_devices: cur_step += 1 - self.notify_frontend("progress", (float(cur_step) / (steps), "Deactivating swap on " + swap_device)) + self.notify_frontend("progress", (float(cur_step) / (steps), _("Deactivating swap on ") + swap_device)) if self._debug: self._logger.log("DEBUG: install_failed_cleanup(): running: swapoff "+swap_device) ret = GLIUtility.spawn("swapoff "+swap_device) if not GLIUtility.exitsuccess(ret): |