summaryrefslogtreecommitdiff
path: root/src/leap/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/gui')
-rw-r--r--src/leap/gui/mainwindow.py72
-rw-r--r--src/leap/gui/ui/wizard.ui1
-rw-r--r--src/leap/gui/wizard.py28
3 files changed, 55 insertions, 46 deletions
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index df21a2bb..d66ddbb5 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -20,6 +20,7 @@ Main window for the leap client
"""
import os
import logging
+import random
from PySide import QtCore, QtGui
@@ -141,9 +142,10 @@ class MainWindow(QtGui.QMainWindow):
self._systray = None
self._vpn_systray = None
- self._action_eip_status = QtGui.QAction("Encryption is OFF", self)
+ self._action_eip_status = QtGui.QAction(self.tr("Encryption is OFF"),
+ self)
self._action_eip_status.setEnabled(False)
- self._action_eip_stop = QtGui.QAction("Stop", self)
+ self._action_eip_stop = QtGui.QAction(self.tr("Stop"), self)
self._action_eip_stop.triggered.connect(
self._stop_eip)
self._action_eip_write = QtGui.QAction(
@@ -155,7 +157,7 @@ class MainWindow(QtGui.QMainWindow):
"0.0 Kb", self)
self._action_eip_read.setEnabled(False)
- self._action_visible = QtGui.QAction("Hide", self)
+ self._action_visible = QtGui.QAction(self.tr("Hide"), self)
self._action_visible.triggered.connect(self._toggle_visible)
self._center_window()
@@ -226,9 +228,9 @@ class MainWindow(QtGui.QMainWindow):
Toggles the window visibility
"""
self.setVisible(not self.isVisible())
- action_visible_text = "Hide"
+ action_visible_text = self.tr("Hide")
if not self.isVisible():
- action_visible_text = "Show"
+ action_visible_text = self.tr("Show")
self._action_visible.setText(action_visible_text)
def _center_window(self):
@@ -257,14 +259,15 @@ class MainWindow(QtGui.QMainWindow):
"""
Display the About LEAP dialog
"""
- QtGui.QMessageBox.about(self, "About LEAP",
- "LEAP is a non-profit dedicated to giving "
- "all internet users access to secure "
- "communication. Our focus is on adapting "
- "encryption technology to make it easy to use "
- "and widely available. "
- "<a href=\"https://leap.se\">More about LEAP"
- "</a>")
+ QtGui.QMessageBox.about(
+ self, self.tr("About LEAP"),
+ self.tr("LEAP is a non-profit dedicated to giving "
+ "all internet users access to secure "
+ "communication. Our focus is on adapting "
+ "encryption technology to make it easy to use "
+ "and widely available. "
+ "<a href=\"https://leap.se\">More about LEAP"
+ "</a>"))
def quit(self):
self._really_quit = True
@@ -399,7 +402,8 @@ class MainWindow(QtGui.QMainWindow):
self._provider_config,
download_if_needed=True)
else:
- self._set_status("Could not load provider configuration")
+ self._set_status(
+ self.tr("Could not load provider configuration"))
self._login_set_enabled(True)
else:
self._set_status(data[self._provider_bootstrapper.ERROR_KEY])
@@ -424,18 +428,18 @@ class MainWindow(QtGui.QMainWindow):
provider = self.ui.cmbProviders.currentText()
if len(provider) == 0:
- self._set_status("Please select a valid provider")
+ self._set_status(self.tr("Please select a valid provider"))
return
if len(username) == 0:
- self._set_status("Please provide a valid username")
+ self._set_status(self.tr("Please provide a valid username"))
return
if len(password) == 0:
- self._set_status("Please provide a valid Password")
+ self._set_status(self.tr("Please provide a valid Password"))
return
- self._set_status("Logging in...")
+ self._set_status(self.tr("Logging in..."))
self._login_set_enabled(False)
self._download_provider_config()
@@ -496,11 +500,11 @@ class MainWindow(QtGui.QMainWindow):
def _start_eip(self):
self._vpn.start(eipconfig=self._eip_config,
providerconfig=self._provider_config,
- socket_host="/home/chiiph/vpnsock",
- socket_port="unix")
+ socket_host="localhost",
+ socket_port=str(random.randint(1000, 9999)))
self._vpn_systray.setVisible(True)
self.ui.btnEipStartStop.setEnabled(True)
- self.ui.btnEipStartStop.setText("Stop EIP")
+ self.ui.btnEipStartStop.setText(self.tr("Stop EIP"))
self.ui.btnEipStartStop.clicked.disconnect(
self._start_eip)
self.ui.btnEipStartStop.clicked.connect(
@@ -509,9 +513,9 @@ class MainWindow(QtGui.QMainWindow):
def _stop_eip(self):
self._vpn.set_should_quit()
self._vpn_systray.setVisible(False)
- self._set_eip_status("EIP has stopped")
+ self._set_eip_status(self.tr("EIP has stopped"))
self._set_eip_status_icon("error")
- self.ui.btnEipStartStop.setText("Start EIP")
+ self.ui.btnEipStartStop.setText(self.tr("Start EIP"))
self.ui.btnEipStartStop.clicked.disconnect(
self._stop_eip)
self.ui.btnEipStartStop.clicked.connect(
@@ -524,7 +528,7 @@ class MainWindow(QtGui.QMainWindow):
leap_assert(self._eip_bootstrapper, "We need an eip bootstrapper!")
leap_assert(self._provider_config, "We need a provider config")
- self._set_eip_status("Checking configuration, please wait...")
+ self._set_eip_status(self.tr("Checking configuration, please wait..."))
if self._provider_config.provides_eip():
self._eip_bootstrapper.run_eip_setup_checks(
@@ -532,7 +536,7 @@ class MainWindow(QtGui.QMainWindow):
self._provider_config,
download_if_needed=True)
else:
- self._set_eip_status("%s does not support EIP" %
+ self._set_eip_status(self.tr("%s does not support EIP") %
(self._provider_config.get_domain(),))
def _set_eip_status_icon(self, status):
@@ -543,11 +547,11 @@ class MainWindow(QtGui.QMainWindow):
@type status: str
"""
selected_pixmap = self.ERROR_ICON
- tray_message = "Encryption is OFF"
- if status in ("AUTH", "GET_CONFIG"):
+ tray_message = self.tr("Encryption is OFF")
+ if status in ("WAIT", "AUTH", "GET_CONFIG"):
selected_pixmap = self.CONNECTING_ICON
elif status in ("CONNECTED"):
- tray_message = "Encryption is ON"
+ tray_message = self.tr("Encryption is ON")
selected_pixmap = self.CONNECTED_ICON
self.ui.lblVPNStatusIcon.setPixmap(selected_pixmap)
@@ -565,11 +569,13 @@ class MainWindow(QtGui.QMainWindow):
status = data[self._vpn.STATUS_STEP_KEY]
self._set_eip_status_icon(status)
if status == "AUTH":
- self._set_eip_status("VPN: Authenticating...")
+ self._set_eip_status(self.tr("VPN: Authenticating..."))
elif status == "GET_CONFIG":
- self._set_eip_status("VPN: Retrieving configuration...")
+ self._set_eip_status(self.tr("VPN: Retrieving configuration..."))
elif status == "CONNECTED":
- self._set_eip_status("VPN: Connected!")
+ self._set_eip_status(self.tr("VPN: Connected!"))
+ elif status == "WAIT":
+ self._set_eip_status(self.tr("VPN: Waiting to start..."))
else:
self._set_eip_status(status)
@@ -621,8 +627,8 @@ class MainWindow(QtGui.QMainWindow):
Starts the logout sequence
"""
self._set_eip_status_icon("error")
- self._set_eip_status("Signing out...")
- self._srp_auth.logout()
+ self._set_eip_status(self.tr("Signing out..."))
+ self._checker_thread.add_checks([self._srp_auth.logout])
def _done_logging_out(self, ok, message):
"""
diff --git a/src/leap/gui/ui/wizard.ui b/src/leap/gui/ui/wizard.ui
index 2d9cb441..a7198c5f 100644
--- a/src/leap/gui/ui/wizard.ui
+++ b/src/leap/gui/ui/wizard.ui
@@ -798,6 +798,7 @@
</tabstops>
<resources>
<include location="../../../../data/resources/mainwindow.qrc"/>
+ <include location="../../../../data/resources/locale.qrc"/>
</resources>
<connections/>
</ui>
diff --git a/src/leap/gui/wizard.py b/src/leap/gui/wizard.py
index bac74d1d..fa705645 100644
--- a/src/leap/gui/wizard.py
+++ b/src/leap/gui/wizard.py
@@ -21,7 +21,7 @@ First run wizard
import os
import logging
-from PySide import QtGui
+from PySide import QtCore, QtGui
from functools import partial
from ui_wizard import Ui_Wizard
@@ -152,19 +152,20 @@ class Wizard(QtGui.QWizard):
username.encode("ascii")
password.encode("ascii")
except:
- message = u"Refrain from using non ASCII áñ characters"
+ message = self.tr(u"Refrain from using non "
+ u"ASCII characters like á, ñ, æ")
if message is not None and password != password2:
- message = "Passwords don't match"
+ message = self.tr("Passwords don't match")
if message is None and len(password) < 6:
- message = "Password too short"
+ message = self.tr("Password too short")
if message is None and password in self.WEAK_PASSWORDS:
- message = "Password too easy"
+ message = self.tr("Password too easy")
if message is None and username == password:
- message = "Password equal to username"
+ message = self.tr("Password equal to username")
if message is not None:
self._set_register_status(message)
@@ -190,20 +191,20 @@ class Wizard(QtGui.QWizard):
self._checker_thread.add_checks(
[partial(register.register_user, username, password)])
self._username = username
- self._set_register_status("Starting registration...")
+ self._set_register_status(self.tr("Starting registration..."))
else:
self.ui.btnRegister.setEnabled(True)
def _registration_finished(self, ok, req):
if ok:
- self._set_register_status("<font color='green'>"
- "<b>User registration OK</b></font>")
+ self._set_register_status(self.tr("<font color='green'>"
+ "<b>User registration OK</b></font>"))
self.ui.lblPassword2.clearFocus()
self.page(self.REGISTER_USER_PAGE).set_completed()
self.button(QtGui.QWizard.BackButton).setEnabled(False)
else:
self._username = None
- error_msg = "Unknown error"
+ error_msg = self.tr("Unknown error")
try:
error_msg = req.json().get("errors").get("login")[0]
except:
@@ -304,7 +305,7 @@ class Wizard(QtGui.QWizard):
new_data = {
self._provider_bootstrapper.PASSED_KEY: False,
self._provider_bootstrapper.ERROR_KEY:
- "Unable to load provider configuration"
+ self.tr("Unable to load provider configuration")
}
self._complete_task(new_data, self.ui.lblProviderInfo)
@@ -387,13 +388,14 @@ class Wizard(QtGui.QWizard):
if pageId == self.PRESENT_PROVIDER_PAGE:
# TODO: get the right lang for these
+ lang = QtCore.QLocale.system().name()
self.ui.lblProviderName.setText(
"<b>%s</b>" %
- (self._provider_config.get_name(),))
+ (self._provider_config.get_name(lang=lang),))
self.ui.lblProviderURL.setText(self._provider_config.get_domain())
self.ui.lblProviderDesc.setText(
"<i>%s</i>" %
- (self._provider_config.get_description(),))
+ (self._provider_config.get_description(lang=lang),))
self.ui.lblProviderPolicy.setText(self._provider_config
.get_enrollment_policy())