From 8fe46a012d17eaa874abf63b9be93c6f11b8df97 Mon Sep 17 00:00:00 2001 From: necoro <> Date: Sun, 5 Aug 2007 04:11:46 +0000 Subject: i18n support and german translations --- portato/gui/gtk/dialogs.py | 17 +++++---- portato/gui/gtk/uncaughtException.py | 12 +++--- portato/gui/gtk/windows.py | 72 ++++++++++++++++++------------------ portato/gui/gtk/wrapper.py | 7 ++-- portato/gui/gui_helper.py | 2 +- 5 files changed, 58 insertions(+), 52 deletions(-) (limited to 'portato/gui') diff --git a/portato/gui/gtk/dialogs.py b/portato/gui/gtk/dialogs.py index 24d1a20..4750bb2 100644 --- a/portato/gui/gtk/dialogs.py +++ b/portato/gui/gtk/dialogs.py @@ -11,9 +11,10 @@ # Written by René 'Necoro' Neumann import gtk +from gettext import lgettext as _ def queue_not_empty_dialog(): - dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, "There are some packages in the emerge queue and/or an emerge process is running.\nDo you really want to quit?") + dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, _("There are some packages in the emerge queue and/or an emerge process is running.\nDo you really want to quit?")) ret = dialog.run() dialog.destroy() return ret @@ -29,44 +30,44 @@ def io_ex_dialog (io_ex): return ret def blocked_dialog (blocked, blocks): - dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, blocked+" is blocked by "+blocks+".\nPlease unmerge the blocking package.") + dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("%(blocked)s is blocked by %(blocks)s.\nPlease unmerge the blocking package.") % {"blocked":blocked, "blocks" : blocks}) ret = dialog.run() dialog.destroy() return ret def not_root_dialog (): - errorMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "You are not root.") + errorMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "_(You are not root.")) ret = errorMB.run() errorMB.destroy() return ret def unmask_dialog (cpv): - dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, cpv+" seems to be masked.\nDo you want to unmask it and its dependencies?") + dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, _("%s seems to be masked.\nDo you want to unmask it and its dependencies?") % cpv) ret = dialog.run() dialog.destroy() return ret def nothing_found_dialog (): - dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "Package not found!") + dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, _("Package not found!")) ret = dialog.run() dialog.destroy() return ret def changed_flags_dialog (what = "flags"): hintMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, - "You have changed %s. Portato will write these changes into the appropriate files. Please backup them if you think it is necessairy." % what) + _("You have changed %s. Portato will write these changes into the appropriate files. Please backup them if you think it is necessairy.") % what) ret = hintMB.run() hintMB.destroy() return ret def remove_deps_dialog (): - infoMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "You cannot remove dependencies. :)") + infoMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, _("You cannot remove dependencies. :)")) ret = infoMB.run() infoMB.destroy() return ret def remove_queue_dialog (): - askMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, "Do you really want to clear the whole queue?") + askMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, _("Do you really want to clear the whole queue?")) ret = askMB.run() askMB.destroy() return ret diff --git a/portato/gui/gtk/uncaughtException.py b/portato/gui/gtk/uncaughtException.py index d8ea13d..04f1a6e 100644 --- a/portato/gui/gtk/uncaughtException.py +++ b/portato/gui/gtk/uncaughtException.py @@ -17,17 +17,19 @@ import sys import gtk, pango from StringIO import StringIO import traceback +from gettext import lgettext as _ + from portato.helper import error class UncaughExceptionDialog(gtk.MessageDialog): def __init__(self, type, value, tb): - super(UncaughExceptionDialog,self).__init__(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_NONE, message_format="A programming error has been detected during the execution of this program.") - self.set_title("Bug Detected") - self.format_secondary_text("It probably isn't fatal, but should be reported to the developers nonetheless.") + super(UncaughExceptionDialog,self).__init__(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_NONE, message_format=_("A programming error has been detected during the execution of this program.")) + self.set_title(_("Bug Detected")) + self.format_secondary_text(_("It probably isn't fatal, but should be reported to the developers nonetheless.")) - self.add_button("Show Details", 1) + self.add_button(_("Show Details"), 1) self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) # Details @@ -74,7 +76,7 @@ def get_trace(type, value, tb): def register_ex_handler(): def handler(*args): - error("An uncaught exception has occured: %s", get_trace(*args)) + error(_("An uncaught exception has occured:\n%s"), get_trace(*args)) UncaughExceptionDialog(*args).run() sys.excepthook = handler diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py index 8cf9fb7..cc70122 100644 --- a/portato/gui/gtk/windows.py +++ b/portato/gui/gtk/windows.py @@ -12,14 +12,13 @@ # gtk stuff import pygtk -pygtk.require("2.0") import gtk import gtk.glade import gobject # our backend stuff from portato.helper import * -from portato.constants import CONFIG_LOCATION, VERSION, DATA_DIR, APP_ICON +from portato.constants import CONFIG_LOCATION, VERSION, DATA_DIR, APP_ICON, APP, LOCALE_DIR from portato.backend import flags, system from portato.backend.exceptions import * @@ -36,7 +35,10 @@ from usetips import UseTips import types, logging from subprocess import Popen from threading import Thread +from gettext import lgettext as _ +gtk.glade.bindtextdomain (APP, LOCALE_DIR) +gtk.glade.textdomain (APP) GLADE_FILE = DATA_DIR+"portato.glade" class Window: @@ -66,7 +68,7 @@ class Window: return wrapper def get_tree (self, name): - return gtk.glade.XML(GLADE_FILE, root = name) + return gtk.glade.XML(GLADE_FILE, name) class Popup: @@ -141,15 +143,15 @@ class PluginWindow (AbstractDialog): view.set_model(self.store) cell = gtk.CellRendererText() - col = gtk.TreeViewColumn("Plugin", cell, markup = 0) + col = gtk.TreeViewColumn(_("Plugin"), cell, markup = 0) view.append_column(col) - col = gtk.TreeViewColumn("Authors", cell, text = 1) + col = gtk.TreeViewColumn(_("Authors"), cell, text = 1) view.append_column(col) bcell = gtk.CellRendererToggle() bcell.connect("toggled", self.cb_plugin_toggled) - col = gtk.TreeViewColumn("Enabled", bcell, active = 2) + col = gtk.TreeViewColumn(_("Enabled"), bcell, active = 2) view.append_column(col) for p in [(""+p.name+"", p.author, p.is_enabled()) for p in plugins]: @@ -195,8 +197,8 @@ class UpdateWindow (AbstractDialog): tCell.set_property("activatable", True) tCell.connect("toggled", self.cb_check_toggled) # emulate the normal toggle behavior ... - self.view.append_column(gtk.TreeViewColumn("Enabled", tCell, active = 0)) - self.view.append_column(gtk.TreeViewColumn("Package", cell, text = 1)) + self.view.append_column(gtk.TreeViewColumn(_("Enabled"), tCell, active = 0)) + self.view.append_column(gtk.TreeViewColumn(_("Package"), cell, text = 1)) for p in self.packages: store.append([False, p.get_cpv()]) @@ -294,7 +296,7 @@ class SearchWindow (AbstractDialog): store.append(["%s/%s" % tuple(p.split("/"))]) cell = gtk.CellRendererText() - col = gtk.TreeViewColumn("Results", cell, markup = 0) + col = gtk.TreeViewColumn(_("Results"), cell, markup = 0) self.searchList.append_column(col) def ok (self, *args): @@ -563,7 +565,7 @@ class PackageTable: def set_desc_label (self): desc = self.actual_package().get_package_settings("DESCRIPTION").replace("&","&") if not desc: - desc = "" + desc = _("") use_markup = False else: desc = ""+desc+"" @@ -592,7 +594,7 @@ class PackageTable: exp = pkg.use_expanded(use, suggest = actual_exp) if exp is not None: if exp != actual_exp: - actual_exp_it = store.append(None, [None, exp, "This is an expanded use flag and cannot be selected"]) + actual_exp_it = store.append(None, [None, exp, "%s" % _("This is an expanded use flag and cannot be selected")]) actual_exp = exp else: actual_exp_it = None @@ -610,9 +612,9 @@ class PackageTable: tCell = gtk.CellRendererToggle() tCell.set_property("activatable", True) tCell.connect("toggled", self.cb_use_flag_toggled, store) - self.useList.append_column(gtk.TreeViewColumn("Enabled", tCell, active = 0)) - self.useList.append_column(gtk.TreeViewColumn("Flags", cell, text = 1)) - self.useList.append_column(gtk.TreeViewColumn("Description", cell, markup = 2)) + self.useList.append_column(gtk.TreeViewColumn(_("Enabled"), tCell, active = 0)) + self.useList.append_column(gtk.TreeViewColumn(_("Flags"), cell, text = 1)) + self.useList.append_column(gtk.TreeViewColumn(_("Description"), cell, markup = 2)) self.useList.set_search_column(1) self.useList.set_enable_tree_lines(True) @@ -627,7 +629,7 @@ class PackageTable: # build view self.versList.set_model(store) - col = gtk.TreeViewColumn("Versions") + col = gtk.TreeViewColumn(("Versions")) # adding the pixbuf cell = gtk.CellRendererPixbuf() @@ -691,7 +693,7 @@ class PackageTable: try: self.queue.append(self.actual_package().get_cpv(), unmerge = True) except PackageNotFoundException, e: - error("Package could not be found: %s", e[0]) + error(_("Package could not be found: %s"), e[0]) #masked_dialog(e[0]) def cb_vers_list_changed (self, *args): @@ -736,33 +738,33 @@ class PackageTable: gtk.Tooltips().set_tip(self.maskedCheck, pkg.get_masking_reason()) # this returns None if it is not masked =) if pkg.is_masked(use_changed = False) and not pkg.is_masked(use_changed = True): - self.maskedCheck.set_label("(Masked)") + self.maskedCheck.set_label("(%s)" % _("Masked")) self.maskedCheck.get_child().set_use_markup(True) else: - self.maskedCheck.set_label("Masked") + self.maskedCheck.set_label(_("Masked")) if pkg.is_locally_masked(): - self.maskedCheck.set_label("Masked") + self.maskedCheck.set_label("%s" % _("Masked")) self.maskedCheck.get_child().set_use_markup(True) self.maskedCheck.set_active(True) else: self.maskedCheck.set_active(pkg.is_masked(use_changed = False)) if pkg.is_testing(use_keywords = False) and not pkg.is_testing(use_keywords = True): - self.testingCheck.set_label("(Testing)") + self.testingCheck.set_label("(%s)" % _("Testing")) self.testingCheck.get_child().set_use_markup(True) else: - self.testingCheck.set_label("Testing") + self.testingCheck.set_label(_("Testing")) self.testingCheck.set_active(pkg.is_testing(use_keywords = False)) if self.doEmerge: # set emerge-button-label if not self.actual_package().is_installed(): - self.emergeBtn.set_label("E_merge") + self.emergeBtn.set_label(_("E_merge")) self.unmergeBtn.set_sensitive(False) else: - self.emergeBtn.set_label("Re_merge") + self.emergeBtn.set_label(_("Re_merge")) self.unmergeBtn.set_sensitive(True) self.table.show_all() @@ -819,12 +821,12 @@ class PackageTable: if not self.actual_package().is_testing(use_keywords = True): self.actual_package().set_testing(False) - button.set_label("Testing") + button.set_label(_("Testing")) button.set_active(True) else: self.actual_package().set_testing(True) if self.actual_package().is_testing(use_keywords=False): - button.set_label("(Testing)") + button.set_label("(%s)" % _("Testing")) button.get_child().set_use_markup(True) button.set_active(True) @@ -847,21 +849,21 @@ class PackageTable: if not pkg.is_masked(use_changed = True): pkg.set_masked(True) if pkg.is_locally_masked(): - button.set_label("Masked") + button.set_label("%s" % _("Masked")) button.get_child().set_use_markup(True) else: - button.set_label("Masked") + button.set_label(_("Masked")) button.set_active(True) else: locally = pkg.is_locally_masked() pkg.set_masked(False) if pkg.is_masked(use_changed=False) and not locally: - button.set_label("(Masked)") + button.set_label("(%s)" % _("Masked")) button.get_child().set_use_markup(True) button.set_active(True) else: - button.set_label("Masked") + button.set_label(_("Masked")) if self.instantChange: self._update_keywords(True, update = True) @@ -1062,10 +1064,10 @@ class MainWindow (Window): self.queueList.set_model(store) cell = gtk.CellRendererText() - col = gtk.TreeViewColumn("Queue", cell, text = 0) + col = gtk.TreeViewColumn(_("Queue"), cell, text = 0) self.queueList.append_column(col) - col = gtk.TreeViewColumn("Options", cell, markup = 1) + col = gtk.TreeViewColumn(_("Options"), cell, markup = 1) self.queueList.append_column(col) self.useTips.add_view(self.queueList) @@ -1083,7 +1085,7 @@ class MainWindow (Window): self.catList.set_model(store) cell = gtk.CellRendererText() - col = gtk.TreeViewColumn("Categories", cell, text = 0) + col = gtk.TreeViewColumn(_("Categories"), cell, text = 0) self.catList.append_column(col) def build_pkg_list (self, name = None): @@ -1098,7 +1100,7 @@ class MainWindow (Window): # build view self.pkgList.set_model(store) - col = gtk.TreeViewColumn("Packages") + col = gtk.TreeViewColumn(_("Packages")) col.set_clickable(True) col.connect("clicked", self.cb_pkg_list_header_clicked) @@ -1159,9 +1161,9 @@ class MainWindow (Window): window_title_update(title) if title is None: - title = "Console" + title = _("Console") else: - title = ("Console (%s)" % title) + title = (_("Console (%(title)s)") % {"title" : title}) return False diff --git a/portato/gui/gtk/wrapper.py b/portato/gui/gtk/wrapper.py index bce4e07..dd06fac 100644 --- a/portato/gui/gtk/wrapper.py +++ b/portato/gui/gtk/wrapper.py @@ -33,13 +33,14 @@ class GtkTree (Tree): string = "" if oneshot: - string += "oneshot" + string += "%s" % _("oneshot") if update: string += "; " if update: - string += "updating" if version is not None: - string += " from version %s" % version + string += "%s" % (_("updating from version %s") % version) + else: + string += "%s" % _("updating") return [cpv, string] diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py index 5c26f58..062a5c3 100644 --- a/portato/gui/gui_helper.py +++ b/portato/gui/gui_helper.py @@ -236,7 +236,7 @@ class Database: return inst+ninst except KeyError: # cat is in category list - but not in portage - info("Catched KeyError => %s seems not to be an available category. Have you played with rsync-excludes?", cat) + info(_("Catched KeyError => %s seems not to be an available category. Have you played with rsync-excludes?"), cat) return [] def reload (self, cat): -- cgit v1.2.3-54-g00ecf