i18n: wrap strings with self.tr

Allow translations to handle strings defined in code.

Fixes QubesOS/qubes-issues#2599
This commit is contained in:
Marek Marczykowski-Górecki 2017-01-22 05:42:38 +01:00
parent cf8b99c763
commit 7c602bf7d2
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
10 changed files with 258 additions and 196 deletions

View File

@ -78,7 +78,7 @@ class BackupVMsWindow(Ui_Backup, QWizard):
self.setupUi(self)
self.progress_status.text = "Backup in progress..."
self.progress_status.text = self.tr("Backup in progress...")
self.show_running_vms_warning(False)
self.dir_line_edit.setReadOnly(False)
@ -224,10 +224,12 @@ class BackupVMsWindow(Ui_Backup, QWizard):
for vm in vms:
self.blk_manager.check_if_serves_as_backend(vm)
reply = QMessageBox.question(None, "VM Shutdown Confirmation",
"Are you sure you want to power down the following VMs: <b>{0}</b>?<br>"
"<small>This will shutdown all the running applications within them.</small>".format(', '.join(names)),
QMessageBox.Yes | QMessageBox.Cancel)
reply = QMessageBox.question(None, self.tr("VM Shutdown Confirmation"),
self.tr("Are you sure you want to power down the following VMs: "
"<b>{0}</b>?<br/>"
"<small>This will shutdown all the running applications "
"within them.</small>").format(', '.join(names)),
QMessageBox.Yes | QMessageBox.Cancel)
self.app.processEvents()
@ -266,7 +268,11 @@ class BackupVMsWindow(Ui_Backup, QWizard):
def validateCurrentPage(self):
if self.currentPage() is self.select_vms_page:
if self.check_running():
QMessageBox.information(None, "Wait!", "Some selected VMs are running. Running VMs can not be backuped. Please shut them down or remove them from the list.")
QMessageBox.information(None,
self.tr("Wait!"),
self.tr("Some selected VMs are running. "
"Running VMs can not be backuped. "
"Please shut them down or remove them from the list."))
return False
self.selected_vms = []
@ -276,18 +282,23 @@ class BackupVMsWindow(Ui_Backup, QWizard):
elif self.currentPage() is self.select_dir_page:
backup_location = str(self.dir_line_edit.text())
if not backup_location:
QMessageBox.information(None, "Wait!", "Enter backup target location first.")
QMessageBox.information(None, self.tr("Wait!"),
self.tr("Enter backup target location first."))
return False
if self.appvm_combobox.currentIndex() == 0 and \
not os.path.isdir(backup_location):
QMessageBox.information(None, "Wait!",
"Selected directory do not exists or not a directory (%s)." % backup_location)
QMessageBox.information(None, self.tr("Wait!"),
self.tr("Selected directory do not exists or "
"not a directory (%s).") % backup_location)
return False
if not len(self.passphrase_line_edit.text()):
QMessageBox.information(None, "Wait!", "Enter passphrase for backup encryption/verification first.")
QMessageBox.information(None, self.tr("Wait!"),
self.tr("Enter passphrase for backup encryption/verification first."))
return False
if self.passphrase_line_edit.text() != self.passphrase_line_edit_verify.text():
QMessageBox.information(None, "Wait!", "Enter the same passphrase in both fields.")
QMessageBox.information(None,
self.tr("Wait!"),
self.tr("Enter the same passphrase in both fields."))
return False
return True
@ -315,7 +326,7 @@ class BackupVMsWindow(Ui_Backup, QWizard):
if ex.tmpdir:
self.tmpdir_to_remove = ex.tmpdir
except Exception as ex:
print "Exception:",ex
print "Exception:", ex
msg.append(str(ex))
if len(msg) > 0 :
@ -340,8 +351,10 @@ class BackupVMsWindow(Ui_Backup, QWizard):
print_callback = self.gather_output,
hide_vm_names=self.encryption_checkbox.isChecked())
except Exception as ex:
print "Exception:",ex
QMessageBox.critical(None, "Error while preparing backup.", "ERROR: {0}".format(ex))
print "Exception:", ex
QMessageBox.critical(None,
self.tr("Error while preparing backup."),
self.tr("ERROR: {0}").format(ex))
self.textEdit.setReadOnly(True)
self.textEdit.setFontFamily("Monospace")
@ -367,25 +380,27 @@ class BackupVMsWindow(Ui_Backup, QWizard):
if not self.thread_monitor.success:
if self.canceled:
self.progress_status.setText("Backup aborted.")
self.progress_status.setText(self.tr("Backup aborted."))
if self.tmpdir_to_remove:
if QMessageBox.warning(None, "Backup aborted",
"Do you want to remove temporary files from "
"%s?" % self.tmpdir_to_remove,
if QMessageBox.warning(None, self.tr("Backup aborted"),
self.tr("Do you want to remove temporary files from "
"%s?") % self.tmpdir_to_remove,
QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes:
shutil.rmtree(self.tmpdir_to_remove)
else:
self.progress_status.setText("Backup error.")
QMessageBox.warning (self, "Backup error!", "ERROR: {}".format(
self.progress_status.setText(self.tr("Backup error."))
QMessageBox.warning(self, self.tr("Backup error!"),
self.tr("ERROR: {}").format(
self.thread_monitor.error_msg))
else:
self.progress_bar.setValue(100)
self.progress_status.setText("Backup finished.")
self.progress_status.setText(self.tr("Backup finished."))
if self.showFileDialog.isChecked():
orig_text = self.progress_status.text
self.progress_status.setText(
orig_text + " Please unmount your backup volume and cancel "
"the file selection dialog.")
orig_text + self.tr(
" Please unmount your backup volume and cancel "
"the file selection dialog."))
if self.target_appvm:
self.target_appvm.run("QUBESRPC %s dom0" % "qubes"
".SelectDirectory")
@ -420,7 +435,7 @@ class BackupVMsWindow(Ui_Backup, QWizard):
# Bases on the original code by:
# Copyright (c) 2002-2007 Pascal Varet <p.varet@gmail.com>
def handle_exception( exc_type, exc_value, exc_traceback ):
def handle_exception(exc_type, exc_value, exc_traceback ):
import sys
import os.path
import traceback

View File

@ -90,9 +90,9 @@ def select_path_button_clicked(dialog, select_file = False):
new_path = get_path_for_vm(vm, "qubes.SelectFile" if select_file
else "qubes.SelectDirectory")
else:
new_path = file_dialog_function(dialog, "Select backup location.",
backup_location if backup_location
else '/')
new_path = file_dialog_function(dialog,
dialog.tr("Select backup location."),
backup_location if backup_location else '/')
if new_path != None:
new_path = unicode(new_path)

View File

@ -99,7 +99,7 @@ class NewVmDlg (QDialog, Ui_NewVMDlg):
for (i, vm) in enumerate(self.template_vm_list):
if vm is self.qvm_collection.get_default_template():
default_index = i
self.template_name.insertItem(i, vm.name + " (default)")
self.template_name.insertItem(i, vm.name + self.tr(" (default)"))
else:
self.template_name.insertItem(i, vm.name)
self.template_name.setCurrentIndex(default_index)
@ -123,7 +123,7 @@ class NewVmDlg (QDialog, Ui_NewVMDlg):
for (i, vm) in enumerate(self.netvm_list):
if vm is self.qvm_collection.get_default_netvm():
default_index = i
self.netvm_name.insertItem(i, vm.name + " (default)")
self.netvm_name.insertItem(i, vm.name + self.tr(" (default)"))
else:
self.netvm_name.insertItem(i, vm.name)
self.netvm_name.setCurrentIndex(default_index)
@ -187,7 +187,10 @@ class NewVmDlg (QDialog, Ui_NewVMDlg):
def accept(self):
vmname = str(self.vmname.text())
if self.qvm_collection.get_vm_by_name(vmname) is not None:
QMessageBox.warning (None, "Incorrect AppVM Name!", "A VM with the name <b>{0}</b> already exists in the system!".format(vmname))
QMessageBox.warning(None,
self.tr("Incorrect AppVM Name!"),
self.tr("A VM with the name <b>{0}</b> already exists in the "
"system!").format(vmname))
return
label = self.label_list[self.vmlabel.currentIndex()]
@ -195,7 +198,11 @@ class NewVmDlg (QDialog, Ui_NewVMDlg):
template_vm = None
if self.template_name.isEnabled():
if len(self.template_vm_list) == 0:
QMessageBox.warning (None, "No template available!", "Cannot create non-standalone VM when no compatible template exists. Create template VM first or choose to create standalone VM.")
QMessageBox.warning(None,
self.tr("No template available!"),
self.tr("Cannot create non-standalone VM when no "
"compatible template exists. Create template VM "
"first or choose to create standalone VM."))
return
template_vm = self.template_vm_list[self.template_name.currentIndex()]
@ -220,8 +227,9 @@ class NewVmDlg (QDialog, Ui_NewVMDlg):
elif self.hvmtpl_radio.isChecked():
vmtype = "TemplateHVM"
else:
QErrorMessage.showMessage(None, "Error creating AppVM!", "Unknown "
"VM type, this is error in Qubes Manager")
QErrorMessage.showMessage(None,
self.tr("Error creating AppVM!"),
self.tr("Unknown VM type, this is error in Qubes Manager"))
self.done(0)
@ -231,7 +239,8 @@ class NewVmDlg (QDialog, Ui_NewVMDlg):
thread.daemon = True
thread.start()
progress = QProgressDialog ("Creating new {0} <b>{1}</b>...".format(vmtype, vmname), "", 0, 0)
progress = QProgressDialog(
self.tr("Creating new {0} <b>{1}</b>...").format(vmtype, vmname), "", 0, 0)
progress.setCancelButton(None)
progress.setModal(True)
progress.show()
@ -246,7 +255,9 @@ class NewVmDlg (QDialog, Ui_NewVMDlg):
self.trayIcon.showMessage(
"VM '{0}' has been created.".format(vmname), msecs=3000)
else:
QMessageBox.warning (None, "Error creating AppVM!", "ERROR: {0}".format(thread_monitor.error_msg))
QMessageBox.warning(None,
self.tr("Error creating AppVM!"),
self.tr("ERROR: {0}").format(thread_monitor.error_msg))
self.done(0)

View File

@ -92,8 +92,8 @@ class NewFwRuleDlg (QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
if self.tcp_radio.isChecked() or self.udp_radio.isChecked():
if len(self.serviceComboBox.currentText()) == 0:
msg = QMessageBox()
msg.warning(self, "Firewall rule",
"You need to fill service name/port for TCP/UDP rule")
msg.warning(self, self.tr("Firewall rule"),
self.tr("You need to fill service name/port for TCP/UDP rule"))
return
QDialog.accept(self)

View File

@ -82,7 +82,7 @@ class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
text = vm.name
if vm is current_update_vm:
self.updatevm_idx = i
text += " (current)"
text += self.tr(" (current)")
self.update_vm_combo.insertItem(i, text)
self.update_vm_combo.insertItem(len(all_vms), "none")
if current_update_vm is None:
@ -97,7 +97,7 @@ class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
text = vm.name
if vm is current_clock_vm:
self.clockvm_idx = i
text += " (current)"
text += self.tr(" (current)")
self.clock_vm_combo.insertItem(i, text)
self.clock_vm_combo.insertItem(len(all_vms), "none")
if current_clock_vm is None:
@ -113,7 +113,7 @@ class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
text = vm.name
if vm is current_netvm:
self.netvm_idx = i
text += " (current)"
text += self.tr(" (current)")
self.default_netvm_combo.insertItem(i, text)
if current_netvm is not None:
self.default_netvm_combo.setCurrentIndex(self.netvm_idx)
@ -127,7 +127,7 @@ class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
text = vm.name
if vm is current_template:
self.template_idx = i
text += " (current)"
text += self.tr(" (current)")
self.default_template_combo.insertItem(i, text)
if current_template is not None:
self.default_template_combo.setCurrentIndex(self.template_idx)
@ -180,9 +180,9 @@ class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
for (i, k) in enumerate(kernel_list):
text = k
if k == self.qvm_collection.get_default_kernel():
text += " (current)"
text += self.tr(" (current)")
self.kernel_idx = i
self.default_kernel_combo.insertItem(i,text)
self.default_kernel_combo.insertItem(i, text)
self.default_kernel_combo.setCurrentIndex(self.kernel_idx)
def __apply_kernel_defaults__(self):

View File

@ -56,7 +56,7 @@ class LogDialog(Ui_LogDialog, QDialog):
log = open(self.log_path)
log.seek(0, os.SEEK_END)
if log.tell() > LOG_DISPLAY_SIZE:
self.displayed_text = "(Showing only last %d bytes of file)\n" % LOG_DISPLAY_SIZE
self.displayed_text = self.tr("(Showing only last %d bytes of file)\n") % LOG_DISPLAY_SIZE
log.seek(-LOG_DISPLAY_SIZE, os.SEEK_END)
else:
log.seek(0, os.SEEK_SET)

View File

@ -95,16 +95,16 @@ class QubesManagerFileWatcher(ProcessEvent):
src_info_file = open(qubes_clipboard_info_file, 'r')
src_vmname = src_info_file.readline().strip('\n')
if src_vmname == "":
trayIcon.showMessage(
trayIcon.showMessage(self.tr(
"Qubes Clipboard has been copied to the VM and wiped.<i/>\n"
"<small>Trigger a paste operation (e.g. Ctrl-v) to insert "
"it into an application.</small>",
"it into an application.</small>"),
msecs=3000)
else:
trayIcon.showMessage(
trayIcon.showMessage(self.tr(
"Qubes Clipboard fetched from VM: <b>'{0}'</b>\n"
"<small>Press Ctrl-Shift-v to copy this clipboard into dest"
" VM's clipboard.</small>".format(
" VM's clipboard.</small>").format(
src_vmname), msecs=3000)
src_info_file.close()
@ -116,7 +116,8 @@ class QubesManagerFileWatcher(ProcessEvent):
EventsCodes.OP_FLAGS.get('IN_CLOSE_WRITE'))
elif event.name == os.path.basename(table_widgets
.qubes_dom0_updates_stat_file):
trayIcon.showMessage("Qubes dom0 updates available.", msecs=0)
trayIcon.showMessage(self.tr("Qubes dom0 updates available."),
msecs=0)
class SearchBox(QLineEdit):
@ -279,12 +280,12 @@ class VmShutdownMonitor(QObject):
if (datetime.now() - self.shutdown_started) > \
timedelta(milliseconds=self.shutdown_time):
reply = QMessageBox.question(
None, "VM Shutdown",
"The VM <b>'{0}'</b> hasn't shutdown within the last "
"{1} seconds, do you want to kill it?<br>".format(
None, self.tr("VM Shutdown"),
self.tr("The VM <b>'{0}'</b> hasn't shutdown within the last "
"{1} seconds, do you want to kill it?<br>").format(
vm.name, self.shutdown_time / 1000),
"Kill it!",
"Wait another {0} seconds...".format(
self.tr("Kill it!"),
self.tr("Wait another {0} seconds...").format(
self.shutdown_time / 1000))
if reply == 0:
vm.force_shutdown()
@ -1027,21 +1028,21 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
dependent_vms = self.qvm_collection.get_vms_based_on(vm.qid)
if len(dependent_vms) > 0:
QMessageBox.warning(
None, "Warning!",
"This Template VM cannot be removed, because there is at "
None, self.tr("Warning!"),
self.tr("This Template VM cannot be removed, because there is at "
"least one AppVM that is based on it.<br>"
"<small>If you want to remove this Template VM and all "
"the AppVMs based on it,"
"you should first remove each individual AppVM that uses "
"this template.</small>")
"this template.</small>"))
return
(requested_name, ok) = QInputDialog.getText(
None, "VM Removal Confirmation",
"Are you sure you want to remove the VM <b>'{0}'</b>?<br>"
None, self.tr("VM Removal Confirmation"),
self.tr("Are you sure you want to remove the VM <b>'{0}'</b>?<br>"
"All data on this VM's private storage will be lost!<br><br>"
"Type the name of the VM (<b>{1}</b>) below to confirm:"
"Type the name of the VM (<b>{1}</b>) below to confirm:")
.format(vm.name, vm.name))
if not ok:
@ -1050,8 +1051,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
elif requested_name != vm.name:
# name did not match
QMessageBox.warning(None, "VM removal confirmation failed",
"Entered name did not match! Not removing {0}.".format(vm.name))
QMessageBox.warning(None, self.tr("VM removal confirmation failed"),
self.tr("Entered name did not match! Not removing {0}.").format(vm.name))
return
else:
@ -1063,7 +1064,7 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
thread.start()
progress = QProgressDialog(
"Removing VM: <b>{0}</b>...".format(vm.name), "", 0, 0)
self.tr("Removing VM: <b>{0}</b>...").format(vm.name), "", 0, 0)
progress.setCancelButton(None)
progress.setModal(True)
progress.show()
@ -1076,10 +1077,10 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
if thread_monitor.success:
trayIcon.showMessage(
"VM '{0}' has been removed.".format(vm.name), msecs=3000)
self.tr("VM '{0}' has been removed.").format(vm.name), msecs=3000)
else:
QMessageBox.warning(None, "Error removing VM!",
"ERROR: {0}".format(
QMessageBox.warning(None, self.tr("Error removing VM!"),
self.tr("ERROR: {0}").format(
thread_monitor.error_msg))
@staticmethod
@ -1119,8 +1120,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
name_number += 1
(clone_name, ok) = QInputDialog.getText(
self, 'Qubes clone VM',
'Enter name for VM <b>' + vm.name + '</b> clone:',
self, self.tr('Qubes clone VM'),
self.tr('Enter name for VM <b>{}</b> clone:').format(vm.name),
text=(name_format % name_number))
if not ok or clone_name == "":
return
@ -1132,7 +1133,7 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
thread.start()
progress = QProgressDialog(
"Cloning VM <b>{0}</b> to <b>{1}</b>...".format(vm.name,
self.tr("Cloning VM <b>{0}</b> to <b>{1}</b>...").format(vm.name,
clone_name), "", 0,
0)
progress.setCancelButton(None)
@ -1146,8 +1147,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
progress.hide()
if not thread_monitor.success:
QMessageBox.warning(None, "Error while cloning VM",
"Exception while cloning:<br>{0}".format(
QMessageBox.warning(None, self.tr("Error while cloning VM"),
self.tr("Exception while cloning:<br>{0}").format(
thread_monitor.error_msg))
@staticmethod
@ -1184,8 +1185,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
try:
vm.resume()
except Exception as ex:
QMessageBox.warning(None, "Error unpausing VM!",
"ERROR: {0}".format(ex))
QMessageBox.warning(None, self.tr("Error unpausing VM!"),
self.tr("ERROR: {0}").format(ex))
return
@ -1199,22 +1200,22 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
thread.daemon = True
thread.start()
trayIcon.showMessage("Starting '{0}'...".format(vm.name), msecs=3000)
trayIcon.showMessage(self.tr("Starting '{0}'...").format(vm.name), msecs=3000)
while not thread_monitor.is_finished():
app.processEvents()
time.sleep(0.1)
if thread_monitor.success:
trayIcon.showMessage("VM '{0}' has been started.".format(vm.name),
trayIcon.showMessage(self.tr("VM '{0}' has been started.").format(vm.name),
msecs=3000)
else:
trayIcon.showMessage(
"Error starting VM <b>'{0}'</b>: {1}".format(
self.tr("Error starting VM <b>'{0}'</b>: {1}").format(
vm.name, thread_monitor.error_msg),
msecs=3000)
self.set_error(vm.qid,
"Error starting VM: %s" % thread_monitor.error_msg)
self.tr("Error starting VM: %s") % thread_monitor.error_msg)
@staticmethod
def do_start_vm(vm, thread_monitor):
@ -1236,9 +1237,9 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
os.path.exists('/usr/lib/qubes/qubes-windows-tools.iso')
if not windows_tools_installed:
msg = QMessageBox()
msg.warning(self, "Error starting VM!",
"You need to install 'qubes-windows-tools' "
"package to use this option")
msg.warning(self, self.tr("Error starting VM!"),
self.tr("You need to install 'qubes-windows-tools' "
"package to use this option"))
return
@ -1248,23 +1249,23 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
thread.daemon = True
thread.start()
trayIcon.showMessage("Starting '{0}'...".format(vm.name), msecs=3000)
trayIcon.showMessage(self.tr("Starting '{0}'...").format(vm.name), msecs=3000)
while not thread_monitor.is_finished():
app.processEvents()
time.sleep(0.1)
if thread_monitor.success:
trayIcon.showMessage("VM '{0}' has been started. Start Qubes "
"Tools installation from attached CD"
trayIcon.showMessage(self.tr("VM '{0}' has been started. Start Qubes "
"Tools installation from attached CD")
.format(vm.name), msecs=3000)
else:
trayIcon.showMessage(
"Error starting VM <b>'{0}'</b>: {1}"
self.tr("Error starting VM <b>'{0}'</b>: {1}")
.format(vm.name, thread_monitor.error_msg),
msecs=3000)
self.set_error(vm.qid,
"Error starting VM: %s" % thread_monitor.error_msg)
self.tr("Error starting VM: %s") % thread_monitor.error_msg)
# noinspection PyMethodMayBeStatic
def do_start_vm_tools_install(self, vm, thread_monitor):
@ -1288,8 +1289,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
try:
vm.pause()
except Exception as ex:
QMessageBox.warning(None, "Error pausing VM!",
"ERROR: {0}".format(ex))
QMessageBox.warning(None, self.tr("Error pausing VM!"),
self.tr("ERROR: {0}").format(ex))
return
@pyqtSlot(name='on_action_shutdownvm_triggered')
@ -1300,10 +1301,10 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
self.blk_manager.check_if_serves_as_backend(vm)
reply = QMessageBox.question(
None, "VM Shutdown Confirmation",
"Are you sure you want to power down the VM <b>'{0}'</b>?<br>"
None, self.tr("VM Shutdown Confirmation"),
self.tr("Are you sure you want to power down the VM <b>'{0}'</b>?<br>"
"<small>This will shutdown all the running applications "
"within this VM.</small>".format(vm.name),
"within this VM.</small>").format(vm.name),
QMessageBox.Yes | QMessageBox.Cancel)
app.processEvents()
@ -1316,11 +1317,11 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
try:
vm.shutdown()
except Exception as ex:
QMessageBox.warning(None, "Error shutting down VM!",
"ERROR: {0}".format(ex))
QMessageBox.warning(None, self.tr("Error shutting down VM!"),
self.tr("ERROR: {0}").format(ex))
return
trayIcon.showMessage("VM '{0}' is shutting down...".format(vm.name),
trayIcon.showMessage(self.tr("VM '{0}' is shutting down...").format(vm.name),
msecs=3000)
self.shutdown_monitor[vm.qid] = VmShutdownMonitor(vm, shutdown_time,
@ -1337,10 +1338,10 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
self.blk_manager.check_if_serves_as_backend(vm)
reply = QMessageBox.question(
None, "VM Restart Confirmation",
"Are you sure you want to restart the VM <b>'{0}'</b>?<br>"
None, self.tr("VM Restart Confirmation"),
self.tr("Are you sure you want to restart the VM <b>'{0}'</b>?<br>"
"<small>This will shutdown all the running applications "
"within this VM.</small>".format(vm.name),
"within this VM.</small>").format(vm.name),
QMessageBox.Yes | QMessageBox.Cancel)
app.processEvents()
@ -1354,10 +1355,10 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
assert vm.is_running() or vm.is_paused()
reply = QMessageBox.question(
None, "VM Kill Confirmation",
"Are you sure you want to kill the VM <b>'{0}'</b>?<br>"
None, self.tr("VM Kill Confirmation"),
self.tr("Are you sure you want to kill the VM <b>'{0}'</b>?<br>"
"<small>This will end <b>(not shutdown!)</b> all the running "
"applications within this VM.</small>".format(vm.name),
"applications within this VM.</small>").format(vm.name),
QMessageBox.Yes | QMessageBox.Cancel,
QMessageBox.Cancel)
@ -1368,9 +1369,9 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
vm.force_shutdown()
except Exception as ex:
QMessageBox.critical(
None, "Error while killing VM!",
"<b>An exception ocurred while killing {0}.</b><br>"
"ERROR: {1}".format(vm.name, ex))
None, self.tr("Error while killing VM!"),
self.tr("<b>An exception ocurred while killing {0}.</b><br>"
"ERROR: {1}").format(vm.name, ex))
return
trayIcon.showMessage("VM '{0}' killed!".format(vm.name), msecs=3000)
@ -1430,13 +1431,13 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
if not vm.is_running():
reply = QMessageBox.question(
None, "VM Update Confirmation",
"<b>{0}</b><br>The VM has to be running to be updated.<br>"
"Do you want to start it?<br>".format(vm.name),
None, self.tr("VM Update Confirmation"),
self.tr("<b>{0}</b><br>The VM has to be running to be updated.<br>"
"Do you want to start it?<br>").format(vm.name),
QMessageBox.Yes | QMessageBox.Cancel)
if reply != QMessageBox.Yes:
return
trayIcon.showMessage("Starting '{0}'...".format(vm.name),
trayIcon.showMessage(self.tr("Starting '{0}'...").format(vm.name),
msecs=3000)
app.processEvents()
@ -1448,8 +1449,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
thread.start()
progress = QProgressDialog(
"<b>{0}</b><br>Please wait for the updater to launch...".format(
vm.name), "", 0, 0)
self.tr("<b>{0}</b><br>Please wait for the updater to launch...").
format(vm.name), "", 0, 0)
progress.setCancelButton(None)
progress.setModal(True)
progress.show()
@ -1462,8 +1463,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
if vm.qid != 0:
if not thread_monitor.success:
QMessageBox.warning(None, "Error VM update!",
"ERROR: {0}".format(
QMessageBox.warning(None, self.tr("Error VM update!"),
self.tr("ERROR: {0}").format(
thread_monitor.error_msg))
@staticmethod
@ -1492,8 +1493,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
vm = self.get_selected_vm()
(command_to_run, ok) = QInputDialog.getText(
self, 'Qubes command entry',
'Run command in <b>' + vm.name + '</b>:')
self, self.tr('Qubes command entry'),
self.tr('Run command in <b>{}</b>:').format(vm.name))
if not ok or command_to_run == "":
return
thread_monitor = ThreadMonitor()
@ -1507,9 +1508,9 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
time.sleep(0.2)
if not thread_monitor.success:
QMessageBox.warning(None, "Error while running command",
"Exception while running command:<br>{0}".format(
thread_monitor.error_msg))
QMessageBox.warning(None, self.tr("Error while running command"),
self.tr("Exception while running command:<br>{0}").format(
thread_monitor.error_msg))
@staticmethod
def do_run_command_in_vm(vm, command_to_run, thread_monitor):
@ -1718,9 +1719,11 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
for d in self.blk_manager.attached_devs:
if (self.blk_manager.attached_devs[d]
['attached_to']['vm'].qid == vm.qid):
text = "Detach " + d + " " + unicode(
self.blk_manager.attached_devs[d]['size']) + " " + \
self.blk_manager.attached_devs[d]['desc']
text = self.tr("Detach {dev} {size} {desc}").format(
dev=d,
size=unicode(
self.blk_manager.attached_devs[d]['size']),
desc=self.blk_manager.attached_devs[d]['desc'])
action = self.blk_menu.addAction(QIcon(":/remove.png"),
text)
action.setData(QVariant(d))
@ -1733,9 +1736,11 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
if d[-1].isdigit() and \
d[0:-1] in self.blk_manager.current_blk:
continue
text = "Attach " + d + " " + unicode(
self.blk_manager.free_devs[d]['size']) + " " + \
self.blk_manager.free_devs[d]['desc']
text = self.tr("Attach {dev} {size} {desc}").format(
dev=d,
size=unicode(
self.blk_manager.free_devs[d]['size']),
desc=self.blk_manager.free_devs[d]['desc'])
action = self.blk_menu.addAction(QIcon(":/add.png"), text)
action.setData(QVariant(d))
@ -1766,7 +1771,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
self.blk_manager.blk_lock.release()
except QubesException as e:
self.blk_manager.blk_lock.release()
QMessageBox.critical(None, "Block attach/detach error!", str(e))
QMessageBox.critical(None,
self.tr("Block attach/detach error!"), str(e))
class QubesTrayIcon(QSystemTrayIcon):
@ -1774,16 +1780,18 @@ class QubesTrayIcon(QSystemTrayIcon):
QSystemTrayIcon.__init__(self, icon)
self.menu = QMenu()
action_showmanager = self.create_action("Open VM Manager",
slot=show_manager, icon="qubes")
action_copy = self.create_action("Copy Dom0 clipboard", icon="copy",
slot=do_dom0_copy)
action_backup = self.create_action("Make backup")
action_preferences = self.create_action("Preferences")
action_set_netvm = self.create_action("Set default NetVM",
action_showmanager = self.create_action(
self.tr("Open VM Manager"),
slot=show_manager, icon="qubes")
action_copy = self.create_action(
self.tr("Copy Dom0 clipboard"), icon="copy",
slot=do_dom0_copy)
action_backup = self.create_action(self.tr("Make backup"))
action_preferences = self.create_action(self.tr("Preferences"))
action_set_netvm = self.create_action(self.tr("Set default NetVM"),
icon="networking")
action_sys_info = self.create_action("System Info", icon="dom0")
action_exit = self.create_action("Exit", slot=exit_app)
action_sys_info = self.create_action(self.tr("System Info"), icon="dom0")
action_exit = self.create_action(self.tr("Exit"), slot=exit_app)
action_backup.setDisabled(True)
action_preferences.setDisabled(True)
@ -1793,8 +1801,8 @@ class QubesTrayIcon(QSystemTrayIcon):
self.blk_manager = blk_manager
self.blk_menu = QMenu(self.menu)
self.blk_menu.setTitle("Block devices")
action_blk_menu = self.create_action("Block devices")
self.blk_menu.setTitle(self.tr("Block devices"))
action_blk_menu = self.create_action(self.tr("Block devices"))
action_blk_menu.setMenu(self.blk_menu)
self.add_actions(self.menu, (action_showmanager,
@ -1825,7 +1833,7 @@ class QubesTrayIcon(QSystemTrayIcon):
self.tray_notifier_type = srv_info.arguments()[1]
if os.path.exists(table_widgets.qubes_dom0_updates_stat_file):
self.showMessage("Qubes dom0 updates available.", msecs=0)
self.showMessage(self.tr("Qubes dom0 updates available."), msecs=0)
def update_blk_menu(self):
global manager_window
@ -1854,11 +1862,11 @@ class QubesTrayIcon(QSystemTrayIcon):
if len(self.blk_manager.attached_devs) > 0:
for d in self.blk_manager.attached_devs:
vm = self.blk_manager.attached_devs[d]['attached_to']['vm']
text = "Detach %s %s (%s) from %s" % (
d,
self.blk_manager.attached_devs[d]['desc'],
unicode(self.blk_manager.attached_devs[d]['size']),
vm.name)
text = self.tr("Detach {dev} {desc} ({size}) from {vm}").format(
dev=d,
desc=self.blk_manager.attached_devs[d]['desc'],
size=unicode(self.blk_manager.attached_devs[d]['size']),
vm=vm.name)
action = self.blk_menu.addAction(QIcon(":/remove.png"), text)
action.setData(QVariant(d))
action.triggered.connect(
@ -1869,10 +1877,10 @@ class QubesTrayIcon(QSystemTrayIcon):
# skip partitions heuristic
if d[-1].isdigit() and d[0:-1] in self.blk_manager.current_blk:
continue
text = "Attach %s %s %s" % (
d,
unicode(self.blk_manager.free_devs[d]['size']),
self.blk_manager.free_devs[d]['desc']
text = self.tr("Attach {dev} {size} {desc}").format(
dev=d,
size=unicode(self.blk_manager.free_devs[d]['size']),
desc=self.blk_manager.free_devs[d]['desc']
)
action = self.blk_menu.addAction(QIcon(":/add.png"), text)
action.setMenu(create_vm_submenu(d))
@ -1892,7 +1900,8 @@ class QubesTrayIcon(QSystemTrayIcon):
self.blk_manager.blk_lock.release()
except QubesException as e:
self.blk_manager.blk_lock.release()
QMessageBox.critical(None, "Block attach/detach error!", str(e))
QMessageBox.critical(None,
self.tr("Block attach/detach error!"), str(e))
@pyqtSlot('QAction *')
def dettach_device_triggered(self, action):
@ -1905,7 +1914,8 @@ class QubesTrayIcon(QSystemTrayIcon):
self.blk_manager.blk_lock.release()
except QubesException as e:
self.blk_manager.blk_lock.release()
QMessageBox.critical(None, "Block attach/detach error!", str(e))
QMessageBox.critical(None,
self.tr("Block attach/detach error!"), str(e))
def icon_clicked(self, reason):
if reason == QSystemTrayIcon.Context:

View File

@ -145,7 +145,7 @@ class RestoreVMsWindow(Ui_Restore, QWizard):
continue
self.select_vms_widget.available_list.addItem(vmname)
except QubesException as ex:
QMessageBox.warning (None, "Restore error!", str(ex))
QMessageBox.warning (None, self.tr("Restore error!"), str(ex))
def __init_restore_options__(self):
if not self.restore_options:
@ -192,24 +192,25 @@ class RestoreVMsWindow(Ui_Restore, QWizard):
except Exception as ex:
print "Exception:", ex
err_msg.append(unicode(ex))
err_msg.append("Partially restored files left in "
"/var/tmp/restore_*, investigate them and/or clean them up")
err_msg.append(
self.tr("Partially restored files left in "
"/var/tmp/restore_*, investigate them and/or clean them up"))
self.qvm_collection.unlock_db()
if self.canceled:
self.emit(SIGNAL("restore_progress(QString)"),
'<b><font color="red">{0}</font></b>'
.format("Restore aborted!"))
.format(self.tr("Restore aborted!")))
elif len(err_msg) > 0 or self.error_detected.is_set():
if len(err_msg) > 0:
thread_monitor.set_error_msg('\n'.join(err_msg))
self.emit(SIGNAL("restore_progress(QString)"),
'<b><font color="red">{0}</font></b>'
.format("Finished with errors!"))
.format(self.tr("Finished with errors!")))
else:
self.emit(SIGNAL("restore_progress(QString)"),
'<font color="green">{0}</font>'
.format("Finished successfully!"))
.format(self.tr("Finished successfully!")))
thread_monitor.set_finished()
@ -263,30 +264,31 @@ class RestoreVMsWindow(Ui_Restore, QWizard):
if not self.thread_monitor.success:
if self.canceled:
if self.tmpdir_to_remove and \
QMessageBox.warning(None, "Restore aborted",
"Do you want to remove temporary "
"files from %s?" % self
.tmpdir_to_remove,
QMessageBox.Yes, QMessageBox.No) == \
QMessageBox.warning(None, self.tr("Restore aborted"),
self.tr("Do you want to remove temporary files "
"from %s?") % self.tmpdir_to_remove,
QMessageBox.Yes, QMessageBox.No) == \
QMessageBox.Yes:
shutil.rmtree(self.tmpdir_to_remove)
else:
QMessageBox.warning (None, "Backup error!", "ERROR: {1}"
.format(self.vm.name, self.thread_monitor.error_msg))
QMessageBox.warning(None,
self.tr("Backup error!"), self.tr("ERROR: {0}")
.format(self.thread_monitor.error_msg))
if self.showFileDialog.isChecked():
self.emit(SIGNAL("restore_progress(QString)"),
'<b><font color="black">{0}</font></b>'.format(
"Please unmount your backup volume and cancel "
"the file selection dialog."))
self.tr(
"Please unmount your backup volume and cancel"
" the file selection dialog.")))
if self.target_appvm:
self.target_appvm.run("QUBESRPC %s dom0" % "qubes"
".SelectDirectory")
self.target_appvm.run("QUBESRPC %s dom0" %
"qubes.SelectDirectory")
else:
file_dialog = QFileDialog()
file_dialog.setReadOnly(True)
file_dialog.getExistingDirectory(
self, "Detach backup device",
self, self.tr("Detach backup device"),
os.path.dirname(unicode(self.dir_line_edit.text())))
self.progress_bar.setValue(100)
self.button(self.FinishButton).setEnabled(True)
@ -308,7 +310,7 @@ class RestoreVMsWindow(Ui_Restore, QWizard):
if backup.backup_cancel():
self.emit(SIGNAL("restore_progress(QString)"),
'<font color="red">{0}</font>'
.format("Aborting the operation..."))
.format(self.tr("Aborting the operation...")))
self.button(self.CancelButton).setDisabled(True)
else:
self.done(0)

View File

@ -54,7 +54,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.source_vm = self.vm
self.setupUi(self)
self.setWindowTitle("Settings: %s" % self.vm.name)
self.setWindowTitle(self.tr("Settings: {vm}").format(vm=self.vm.name))
if init_page in self.tabs_indices:
idx = self.tabs_indices[init_page]
assert (idx in range(self.tabWidget.count()))
@ -118,7 +118,8 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
thread.daemon = True
thread.start()
progress = QProgressDialog ("Applying settings to <b>{0}</b>...".format(self.vm.name), "", 0, 0)
progress = QProgressDialog(
self.tr("Applying settings to <b>{0}</b>...").format(self.vm.name), "", 0, 0)
progress.setCancelButton(None)
progress.setModal(True)
progress.show()
@ -130,8 +131,9 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
progress.hide()
if not thread_monitor.success:
QMessageBox.warning (None, "Error while changing settings for {0}!".format(self.vm.name),
"ERROR: {0}".format(thread_monitor.error_msg))
QMessageBox.warning(None,
self.tr("Error while changing settings for {0}!").format(self.vm.name),
self.tr("ERROR: {0}").format(thread_monitor.error_msg))
self.done(0)
@ -155,7 +157,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
if len(ret_tmp) > 0:
ret += ["Sevices tab:"] + ret_tmp
except Exception as ex:
ret.append('Error while saving changes: ' + str(ex))
ret.append(self.tr('Error while saving changes: ') + str(ex))
if self.anything_changed == True:
self.qvm_collection.save()
@ -170,13 +172,13 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.tempFullAccess.isChecked(),
self.tempFullAccessTime.value())
except Exception as ex:
ret += ["Firewall tab:", str(ex)]
ret += [self.tr("Firewall tab:"), str(ex)]
try:
if self.tabWidget.isTabEnabled(self.tabs_indices["applications"]):
self.AppListManager.save_appmenu_select_changes()
except Exception as ex:
ret += ["Applications tab:", str(ex)]
ret += [self.tr("Applications tab:"), str(ex)]
if len(ret) > 0 :
thread_monitor.set_error_msg('\n'.join(ret))
@ -187,8 +189,13 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
def current_tab_changed(self, idx):
if idx == self.tabs_indices["firewall"]:
if self.vm.netvm is not None and not self.vm.netvm.is_proxyvm():
QMessageBox.warning (None, "VM configuration problem!", "The '{0}' AppVM is not network connected to a FirewallVM!<p>".format(self.vm.name) +\
"You may edit the '{0}' VM firewall rules, but these will not take any effect until you connect it to a working Firewall VM.".format(self.vm.name))
QMessageBox.warning(None,
self.tr("VM configuration problem!"),
self.tr("The '{vm}' AppVM is not network connected to a "
"FirewallVM!<p>"
"You may edit the '{vm}' VM firewall rules, but these "
"will not take any effect until you connect it to "
"a working Firewall VM.").format(vm=self.vm.name))
@ -228,10 +235,10 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
continue
text = vm.name
if vm is self.qvm_collection.get_default_template():
text += " (default)"
text += self.tr(" (default)")
if vm.qid == self.vm.template.qid:
self.template_idx = i
text += " (current)"
text += self.tr(" (current)")
self.template_name.insertItem(i, text)
i += 1
self.template_name.setCurrentIndex(self.template_idx)
@ -249,7 +256,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
if default_netvm is not None:
text = "default (%s)" % default_netvm.name
if self.vm.uses_default_netvm:
text += " (current)"
text += self.tr(" (current)")
self.netvm_idx = 0
self.netVM.insertItem(0, text)
@ -257,12 +264,12 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
text = vm.name
if self.vm.netvm is not None and vm.qid == self.vm.netvm.qid and not self.vm.uses_default_netvm:
self.netvm_idx = i+1
text += " (current)"
text += self.tr(" (current)")
self.netVM.insertItem(i+1, text)
none_text = "none"
if self.vm.netvm is None:
none_text += " (current)"
none_text += self.tr(" (current)")
self.netvm_idx = len(netvm_list)+1
self.netVM.insertItem(len(netvm_list)+1, none_text)
@ -326,9 +333,11 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
vmname = str(self.vmname.text())
if self.vm.name != vmname:
if self.vm.is_running():
msg.append("Can't change name of a running VM.")
msg.append(self.tr("Can't change name of a running VM."))
elif self.qvm_collection.get_vm_by_name(vmname) is not None:
msg.append("Can't change VM name - a VM named <b>{0}</b> already exists in the system!".format(vmname))
msg.append(
self.tr("Can't change VM name - a VM named <b>{0}</b>"
"already exists in the system!").format(vmname))
else:
oldname = self.vm.name
try:
@ -442,11 +451,18 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
def check_mem_changes(self):
if self.max_mem_size.value() < self.init_mem.value():
QMessageBox.warning(None, "Warning!", "Max memory can not be less than initial memory.<br>Setting max memory to equal initial memory.")
QMessageBox.warning(None,
self.tr("Warning!"),
self.tr("Max memory can not be less than initial memory.<br>"
"Setting max memory to equal initial memory."))
self.max_mem_size.setValue(self.init_mem.value())
# Linux specific limit: init memory must not be below max_mem_size/10.79 in order to allow scaling up to max_mem_size (or else "add_memory() failed: -17" problem)
if self.init_mem.value() * 10 < self.max_mem_size.value():
QMessageBox.warning(None, "Warning!", "Initial memory can not be less than one tenth Max memory.<br>Setting initial memory to the minimum allowed value.")
QMessageBox.warning(None,
self.tr("Warning!"),
self.tr("Initial memory can not be less than one tenth "
"Max memory.<br>Setting initial memory to the minimum "
"allowed value."))
self.init_mem.setValue(self.max_mem_size.value() / 10)
@ -563,7 +579,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
text = "default (same as VM own NetVM)"
if self.vm.uses_default_dispvm_netvm:
text += " (current)"
text += self.tr(" (current)")
self.dispvm_netvm_idx = 0
self.dispvm_netvm.insertItem(0, text)
@ -573,12 +589,12 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.vm.dispvm_netvm.qid and not \
self.vm.uses_default_dispvm_netvm:
self.dispvm_netvm_idx = i+1
text += " (current)"
text += self.tr(" (current)")
self.dispvm_netvm.insertItem(i+1, text)
none_text = "none"
if self.vm.dispvm_netvm is None:
none_text += " (current)"
none_text += self.tr(" (current)")
self.dispvm_netvm_idx = len(netvm_list)+1
self.dispvm_netvm.insertItem(len(netvm_list)+1, none_text)
@ -804,7 +820,8 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
srv = str(self.service_line_edit.text()).strip()
if srv != "":
if srv in self.new_srv_dict:
QMessageBox.information(None, "", "Service already on the list!")
QMessageBox.information(None, "",
self.tr("Service already on the list!"))
else:
item = QListWidgetItem(srv)
item.setCheckState(QtCore.Qt.Checked)
@ -817,7 +834,9 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
if not item:
return
if str(item.text()) == 'meminfo-writer':
QMessageBox.information(None, "Service can not be removed", "Service meminfo-writer can not be removed from the list.")
QMessageBox.information(None,
self.tr("Service can not be removed"),
self.tr("Service meminfo-writer can not be removed from the list."))
return
row = self.services_list.currentRow()
@ -958,8 +977,9 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
if port is not None:
if port2 is not None and port2 <= port:
QMessageBox.warning(None, "Invalid service ports range",
"Port {0} is lower than port {1}.".format(port2, port))
QMessageBox.warning(None, self.tr("Invalid service ports range"),
self.tr("Port {0} is lower than port {1}.").format(
port2, port))
else:
item = {"address": address,
"netmask": netmask,
@ -972,8 +992,8 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
else:
self.fw_model.appendChild(item)
else:
QMessageBox.warning(None, "Invalid service name",
"Service '{0}' is unknown.".format(service))
QMessageBox.warning(None, self.tr("Invalid service name"),
self.tr("Service '{0}' is unknown.").format(service))
# Bases on the original code by:

View File

@ -605,16 +605,20 @@ class VmUpdateInfoWidget(QWidget):
if state == "update":
label_text = "<font color=\"#CCCC00\">Check updates</font>"
icon_path = ":/update-recommended.png"
tooltip_text = "Updates pending!"
tooltip_text = self.tr("Updates pending!")
elif state == "outdated":
label_text = "<font color=\"red\">VM outdated</font>"
icon_path = ":/outdated.png"
tooltip_text = "The VM must be restarted for its filesystem to reflect the template's recent committed changes."
tooltip_text = self.tr(
"The VM must be restarted for its filesystem to reflect the "
"template's recent committed changes.")
elif state == "to-be-outdated":
label_text = "<font color=\"#800000\">TemplateVM running</font>"
icon_path = ":/to-be-outdated.png"
tooltip_text = "The TemplateVM must be stopped before changes from its current session can be picked up by this VM."
elif state == None:
tooltip_text = self.tr(
"The TemplateVM must be stopped before changes from its "
"current session can be picked up by this VM.")
elif state is None:
label_text = ""
icon_path = None
tooltip_text = None
@ -624,7 +628,7 @@ class VmUpdateInfoWidget(QWidget):
else:
self.layout().removeWidget(self.icon)
self.icon.deleteLater()
if icon_path != None:
if icon_path is not None:
self.icon = VmIconWidget(icon_path, True, 0.7)
self.icon.setToolTip(tooltip_text)
else: