mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Added gettext support. Internationalize all strings which could be shown to user. Fix about dialog to show corect version number
This commit is contained in:
parent
439c44a384
commit
84d9b81bda
@ -35,8 +35,10 @@ EXTRA_DIST = $(bin_SOURCES) $(desktop_SOURCES) $(dbus_SOURCES) $(python_SOURCES)
|
||||
|
||||
%.py: $(srcdir)/%.py.in
|
||||
sed -e "s,::PACKAGE::,$(PACKAGE)," \
|
||||
-e "s,::VERSION::,$(VERSION)," \
|
||||
-e "s,::ASSETDIR::,$(pkgdatadir)," \
|
||||
-e "s,::PYLIBDIR::,$(pkgdatadir)," \
|
||||
-e "s,::GETTEXTDIR::,$(datadir)/locale," \
|
||||
-e "s,::PYARCHLIBDIR::,$(pkglibdir)," < $< > $@
|
||||
|
||||
$(PACKAGE): $(srcdir)/$(PACKAGE).in
|
||||
|
@ -18,6 +18,23 @@
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
|
||||
from os import getcwd
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
import locale
|
||||
import gettext
|
||||
|
||||
gettext_app = "virt-manager"
|
||||
gettext_dir = "::GETTEXTDIR::"
|
||||
|
||||
if os.path.exists(os.getcwd() + "/locale/en.po"):
|
||||
gettext_dir = os.getcwd() + "/locale"
|
||||
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
gettext.install(gettext_app, gettext_dir)
|
||||
|
||||
|
||||
import gtk
|
||||
gtk.gdk.threads_init()
|
||||
|
||||
@ -25,13 +42,10 @@ import dbus
|
||||
import dbus.glib
|
||||
import dbus.service
|
||||
|
||||
from os import getcwd
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
from optparse import OptionParser
|
||||
|
||||
appname = "::PACKAGE::"
|
||||
appversion = "::VERSION::"
|
||||
gconf_dir = "/apps/" + appname
|
||||
asset_dir = "::ASSETDIR::"
|
||||
glade_dir = asset_dir
|
||||
@ -45,7 +59,9 @@ if os.path.exists(os.getcwd() + "/src/" + appname + ".glade"):
|
||||
if os.path.exists(os.getcwd() + "/pixmaps/icon_run.png"):
|
||||
icon_dir = os.getcwd() + "/pixmaps"
|
||||
|
||||
if os.path.exists(os.getcwd() + "/src/virtManager/__init__.py"):
|
||||
if os.path.exists(os.getcwd() + "/src/virt-manager.py"):
|
||||
sys.path.insert(0, os.getcwd() + "/src/graphWidgets/.libs")
|
||||
elif os.path.exists(os.getcwd() + "/build/src/virt-manager.py"):
|
||||
sys.path.insert(0, os.getcwd() + "/src")
|
||||
sys.path.insert(0, os.getcwd() + "/build/src/graphWidgets/.libs")
|
||||
else:
|
||||
@ -65,7 +81,7 @@ def main():
|
||||
|
||||
(options, args) = optParser.parse_args()
|
||||
|
||||
config = vmmConfig(appname, gconf_dir, glade_dir, icon_dir)
|
||||
config = vmmConfig(appname, appversion, gconf_dir, glade_dir, icon_dir)
|
||||
engine = vmmEngine(config)
|
||||
bus = None
|
||||
try:
|
||||
@ -90,7 +106,7 @@ def main():
|
||||
return
|
||||
except:
|
||||
print str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
|
||||
print "Could not connection to session bus, disabling DBus service"
|
||||
print _("Could not connection to session bus, disabling DBus service")
|
||||
if options.uri != None:
|
||||
engine.show_manager(options.uri)
|
||||
else:
|
||||
|
@ -23,6 +23,7 @@ class vmmAbout:
|
||||
def __init__(self, config):
|
||||
self.window = gtk.glade.XML(config.get_glade_file(), "vmm-about")
|
||||
self.window.get_widget("vmm-about").hide()
|
||||
self.config = config
|
||||
|
||||
self.window.signal_autoconnect({
|
||||
"on_vmm_about_delete_event": self.close,
|
||||
@ -30,7 +31,7 @@ class vmmAbout:
|
||||
|
||||
def show(self):
|
||||
dialog = self.window.get_widget("vmm-about")
|
||||
dialog.set_version("0.1")
|
||||
dialog.set_version(self.config.get_appversion())
|
||||
dialog.show_all()
|
||||
dialog.present()
|
||||
|
||||
|
@ -23,8 +23,9 @@ import gtk.gdk
|
||||
from virtManager.keyring import *
|
||||
|
||||
class vmmConfig:
|
||||
def __init__(self, appname, gconf_dir, glade_dir, icon_dir):
|
||||
def __init__(self, appname, appversion, gconf_dir, glade_dir, icon_dir):
|
||||
self.appname = appname
|
||||
self.appversion = appversion
|
||||
self.conf_dir = gconf_dir
|
||||
self.conf = gconf.client_get_default()
|
||||
self.conf.add_dir (gconf_dir,
|
||||
@ -54,6 +55,9 @@ class vmmConfig:
|
||||
def get_appname(self):
|
||||
return self.appname
|
||||
|
||||
def get_appversion(self):
|
||||
return self.appversion
|
||||
|
||||
def get_glade_dir(self):
|
||||
return self.glade_dir
|
||||
|
||||
@ -170,7 +174,7 @@ class vmmConfig:
|
||||
try:
|
||||
self.keyring = vmmKeyring()
|
||||
except:
|
||||
print "Unable to access keyring"
|
||||
print _("Unable to access keyring")
|
||||
return
|
||||
|
||||
self.keyring.clear_secret(id)
|
||||
@ -184,7 +188,7 @@ class vmmConfig:
|
||||
try:
|
||||
self.keyring = vmmKeyring()
|
||||
except:
|
||||
print "Unable to access keyring"
|
||||
print _("Unable to access keyring")
|
||||
return ""
|
||||
|
||||
secret = self.keyring.get_secret(id)
|
||||
@ -198,7 +202,7 @@ class vmmConfig:
|
||||
try:
|
||||
self.keyring = vmmKeyring()
|
||||
except:
|
||||
print "Unable to access keyring"
|
||||
print _("Unable to access keyring")
|
||||
return
|
||||
|
||||
# Nb, we don't bother to check if there is an existing
|
||||
|
@ -140,7 +140,7 @@ class vmmConsole(gobject.GObject):
|
||||
try:
|
||||
self.vncViewer.connect_to_host(host, port)
|
||||
except:
|
||||
print "Unable to activate console"
|
||||
print _("Unable to activate console")
|
||||
self.activate_unavailable_page()
|
||||
return
|
||||
if self.vncViewer.is_authenticated():
|
||||
@ -186,7 +186,7 @@ class vmmConsole(gobject.GObject):
|
||||
if not(status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]):
|
||||
self.vm.shutdown()
|
||||
else:
|
||||
print "Shutdown requested, but machine is already shutting down / shutoff"
|
||||
print _("Shutdown requested, but machine is already shutting down / shutoff")
|
||||
|
||||
def control_vm_pause(self, src):
|
||||
if self.ignorePause:
|
||||
@ -194,18 +194,18 @@ class vmmConsole(gobject.GObject):
|
||||
|
||||
status = self.vm.status()
|
||||
if status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]:
|
||||
print "Pause/resume requested, but machine is shutdown / shutoff"
|
||||
print _("Pause/resume requested, but machine is shutdown / shutoff")
|
||||
else:
|
||||
if status in [ libvirt.VIR_DOMAIN_PAUSED ]:
|
||||
if not src.get_active():
|
||||
self.vm.resume()
|
||||
else:
|
||||
print "Pause requested, but machine is already paused"
|
||||
print _("Pause requested, but machine is already paused")
|
||||
else:
|
||||
if src.get_active():
|
||||
self.vm.suspend()
|
||||
else:
|
||||
print "Resume requested, but machine is already running"
|
||||
print _("Resume requested, but machine is already running")
|
||||
|
||||
def control_vm_terminal(self, src):
|
||||
self.emit("action-launch-terminal", self.vm.get_connection().get_uri(), self.vm.get_uuid())
|
||||
@ -271,7 +271,7 @@ class vmmConsole(gobject.GObject):
|
||||
cr.set_source_rgba(1, 1,1, 1)
|
||||
cr.set_font_size(80)
|
||||
cr.select_font_face("Sans", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
|
||||
overlay = "paused"
|
||||
overlay = _("paused")
|
||||
extents = cr.text_extents(overlay)
|
||||
x = width/2 - (extents[2]/2)
|
||||
y = height/2 - (extents[3]/2)
|
||||
@ -285,7 +285,7 @@ class vmmConsole(gobject.GObject):
|
||||
else:
|
||||
self.try_login()
|
||||
except:
|
||||
print "Couldn't open console " + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
|
||||
print _("Couldn't open console: ") + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
|
||||
self.ignorePause = False
|
||||
self.ignorePause = False
|
||||
|
||||
|
@ -164,7 +164,7 @@ class vmmDetails(gobject.GObject):
|
||||
if not(status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]):
|
||||
self.vm.shutdown()
|
||||
else:
|
||||
print "Shutdown requested, but machine is already shutting down / shutoff"
|
||||
print _("Shutdown requested, but machine is already shutting down / shutoff")
|
||||
|
||||
def control_vm_pause(self, src):
|
||||
if self.ignorePause:
|
||||
@ -172,18 +172,18 @@ class vmmDetails(gobject.GObject):
|
||||
|
||||
status = self.vm.status()
|
||||
if status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]:
|
||||
print "Pause/resume requested, but machine is shutdown / shutoff"
|
||||
print _("Pause/resume requested, but machine is shutdown / shutoff")
|
||||
else:
|
||||
if status in [ libvirt.VIR_DOMAIN_PAUSED ]:
|
||||
if not src.get_active():
|
||||
self.vm.resume()
|
||||
else:
|
||||
print "Pause requested, but machine is already paused"
|
||||
print _("Pause requested, but machine is already paused")
|
||||
else:
|
||||
if src.get_active():
|
||||
self.vm.suspend()
|
||||
else:
|
||||
print "Resume requested, but machine is already running"
|
||||
print _("Resume requested, but machine is already running")
|
||||
|
||||
def control_vm_terminal(self, src):
|
||||
self.emit("action-launch-terminal", self.vm.get_connection().get_uri(), self.vm.get_uuid())
|
||||
|
@ -248,17 +248,17 @@ class vmmDomain(gobject.GObject):
|
||||
|
||||
def run_status(self):
|
||||
if self.lastStatus == libvirt.VIR_DOMAIN_RUNNING:
|
||||
return "Running"
|
||||
return _("Running")
|
||||
elif self.lastStatus == libvirt.VIR_DOMAIN_PAUSED:
|
||||
return "Paused"
|
||||
return _("Paused")
|
||||
elif self.lastStatus == libvirt.VIR_DOMAIN_SHUTDOWN:
|
||||
return "Shutdown"
|
||||
return _("Shutdown")
|
||||
elif self.lastStatus == libvirt.VIR_DOMAIN_SHUTOFF:
|
||||
return "Shutoff"
|
||||
return _("Shutoff")
|
||||
elif self.lastStatus == libvirt.VIR_DOMAIN_CRASHED:
|
||||
return "Crashed"
|
||||
return _("Crashed")
|
||||
else:
|
||||
raise "Unknown status code"
|
||||
raise _("Unknown status code")
|
||||
|
||||
def run_status_icon(self):
|
||||
status = self.run_status()
|
||||
|
@ -60,7 +60,7 @@ class vmmEngine:
|
||||
conn = self.get_connection(uri, readOnly)
|
||||
self.show_manager(uri)
|
||||
except:
|
||||
print "Unable to open connection to hypervisor URI '" + str(uri) + "'"
|
||||
print _("Unable to open connection to hypervisor URI '%s'") % str(uri)
|
||||
print str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
|
||||
|
||||
if len(self.connections.keys()) == 0:
|
||||
@ -100,7 +100,7 @@ class vmmEngine:
|
||||
raise KeyboardInterrupt
|
||||
except:
|
||||
print str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])
|
||||
print "Error refreshing connection " + uri
|
||||
print _("Error refreshing connection '%s'") % uri
|
||||
return 1
|
||||
|
||||
def change_timer_interval(self,ignore1,ignore2,ignore3,ignore4):
|
||||
@ -209,20 +209,21 @@ class vmmEngine:
|
||||
libvirt.VIR_DOMAIN_SHUTOFF,
|
||||
libvirt.VIR_DOMAIN_CRASHED,
|
||||
libvirt.VIR_DOMAIN_PAUSED ]:
|
||||
print "Save requested, but machine is shutdown / shutoff / paused"
|
||||
print _("Save requested, but machine is shutdown / shutoff / paused")
|
||||
else:
|
||||
self.fcdialog = gtk.FileChooserDialog("Save Virtual Machine",
|
||||
src.window.get_widget("vmm-details"),
|
||||
gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT),
|
||||
None)
|
||||
self.fcdialog = gtk.FileChooserDialog(_("Save Virtual Machine"),
|
||||
src.window.get_widget("vmm-details"),
|
||||
gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT),
|
||||
None)
|
||||
self.fcdialog.set_do_overwrite_confirmation(True)
|
||||
response = self.fcdialog.run()
|
||||
self.fcdialog.hide()
|
||||
if(response == gtk.RESPONSE_ACCEPT):
|
||||
file_to_save = self.fcdialog.get_filename()
|
||||
progWin = vmmAsyncJob(self.config, vm.save,
|
||||
[file_to_save], "Saving Virtual Machine")
|
||||
[file_to_save],
|
||||
_("Saving Virtual Machine"))
|
||||
progWin.run()
|
||||
self.fcdialog.destroy()
|
||||
|
@ -147,7 +147,7 @@ class vmmManager(gobject.GObject):
|
||||
|
||||
def restore_saved(self, src=None):
|
||||
# get filename
|
||||
self.fcdialog = gtk.FileChooserDialog("Restore Virtual Machine",
|
||||
self.fcdialog = gtk.FileChooserDialog(_("Restore Virtual Machine"),
|
||||
self.window.get_widget("vmm-manager"),
|
||||
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
@ -158,8 +158,10 @@ class vmmManager(gobject.GObject):
|
||||
self.fcdialog.hide()
|
||||
if(response == gtk.RESPONSE_ACCEPT):
|
||||
file_to_load = self.fcdialog.get_filename()
|
||||
progWin = vmmAsyncJob(self.config, self.restore_saved_callback,
|
||||
[file_to_load], "Restoring Virtual Machine")
|
||||
progWin = vmmAsyncJob(self.config,
|
||||
self.restore_saved_callback,
|
||||
[file_to_load],
|
||||
_("Restoring Virtual Machine"))
|
||||
progWin.run()
|
||||
|
||||
self.fcdialog.destroy()
|
||||
@ -177,8 +179,7 @@ class vmmManager(gobject.GObject):
|
||||
def restore_saved_callback(self, file_to_load):
|
||||
status = self.connection.restore(file_to_load)
|
||||
if(status != 0):
|
||||
self.domain_restore_error = "Error restoring domain " + file_to_load + \
|
||||
". Is the domain already running?"
|
||||
self.domain_restore_error = _("Error restoring domain '%s'. Is the domain already running?") % file_to_load
|
||||
|
||||
|
||||
def vm_added(self, connection, uri, vmuuid):
|
||||
@ -274,14 +275,14 @@ class vmmManager(gobject.GObject):
|
||||
model = gtk.ListStore(str, str)
|
||||
vmlist.set_model(model)
|
||||
|
||||
idCol = gtk.TreeViewColumn("ID")
|
||||
nameCol = gtk.TreeViewColumn("Name")
|
||||
statusCol = gtk.TreeViewColumn("Status")
|
||||
cpuUsageCol = gtk.TreeViewColumn("CPU usage")
|
||||
virtualCPUsCol = gtk.TreeViewColumn("VCPUs")
|
||||
memoryUsageCol = gtk.TreeViewColumn("Memory usage")
|
||||
diskUsageCol = gtk.TreeViewColumn("Disk usage")
|
||||
networkTrafficCol = gtk.TreeViewColumn("Network traffic")
|
||||
idCol = gtk.TreeViewColumn(_("ID"))
|
||||
nameCol = gtk.TreeViewColumn(_("Name"))
|
||||
statusCol = gtk.TreeViewColumn(_("Status"))
|
||||
cpuUsageCol = gtk.TreeViewColumn(_("CPU usage"))
|
||||
virtualCPUsCol = gtk.TreeViewColumn(_("VCPUs"))
|
||||
memoryUsageCol = gtk.TreeViewColumn(_("Memory usage"))
|
||||
diskUsageCol = gtk.TreeViewColumn(_("Disk usage"))
|
||||
networkTrafficCol = gtk.TreeViewColumn(_("Network traffic"))
|
||||
|
||||
vmlist.append_column(idCol)
|
||||
vmlist.append_column(nameCol)
|
||||
|
Loading…
Reference in New Issue
Block a user