Commit 5d0363b6 authored by Tijmen de Mes's avatar Tijmen de Mes

Allow python strings to be translated

parent d0a4a70d
...@@ -3,7 +3,7 @@ from PyQt5 import uic ...@@ -3,7 +3,7 @@ from PyQt5 import uic
from blink import __date__, __version__ from blink import __date__, __version__
from blink.resources import Resources from blink.resources import Resources
from blink.util import QSingleton from blink.util import QSingleton, translate
__all__ = ['AboutPanel'] __all__ = ['AboutPanel']
...@@ -41,7 +41,7 @@ class AboutPanel(base_class, ui_class, metaclass=QSingleton): ...@@ -41,7 +41,7 @@ class AboutPanel(base_class, ui_class, metaclass=QSingleton):
with Resources.directory: with Resources.directory:
self.setupUi(self) self.setupUi(self)
self.version.setText('Version %s\n%s' % (__version__, __date__)) self.version.setText(translate('about_panel', 'Version %s\n%s') % (__version__, __date__))
credits_width = self.credits_text.fontMetrics().width("NLnet Foundation" + "http://sipsimpleclient.org") + 40 credits_width = self.credits_text.fontMetrics().width("NLnet Foundation" + "http://sipsimpleclient.org") + 40
self.credits_text.setFixedWidth(credits_width) self.credits_text.setFixedWidth(credits_width)
......
...@@ -32,7 +32,7 @@ from blink.contacts import URIUtils ...@@ -32,7 +32,7 @@ from blink.contacts import URIUtils
from blink.resources import ApplicationData, IconManager, Resources from blink.resources import ApplicationData, IconManager, Resources
from blink.sessions import SessionManager, StreamDescription from blink.sessions import SessionManager, StreamDescription
from blink.widgets.labels import Status from blink.widgets.labels import Status
from blink.util import QSingleton, call_in_gui_thread, run_in_gui_thread from blink.util import QSingleton, call_in_gui_thread, run_in_gui_thread, translate
__all__ = ['AccountModel', 'ActiveAccountModel', 'AccountSelector', 'AddAccountDialog', 'ServerToolsAccountModel', 'ServerToolsWindow'] __all__ = ['AccountModel', 'ActiveAccountModel', 'AccountSelector', 'AddAccountDialog', 'ServerToolsAccountModel', 'ServerToolsWindow']
...@@ -379,7 +379,7 @@ class AddAccountDialog(base_class, ui_class, metaclass=QSingleton): ...@@ -379,7 +379,7 @@ class AddAccountDialog(base_class, ui_class, metaclass=QSingleton):
self.accept() self.accept()
else: else:
self.setEnabled(False) self.setEnabled(False)
self.create_status_label.value = Status('Creating account on server...') self.create_status_label.value = Status(translate('add_account_dialog', 'Creating account on server...'))
self._create_sip_account(self.username, self.password, self.email_address, self.display_name) self._create_sip_account(self.username, self.password, self.email_address, self.display_name)
def _SH_PanelChangeRequest(self, index): def _SH_PanelChangeRequest(self, index):
...@@ -397,28 +397,28 @@ class AddAccountDialog(base_class, ui_class, metaclass=QSingleton): ...@@ -397,28 +397,28 @@ class AddAccountDialog(base_class, ui_class, metaclass=QSingleton):
red = '#cc0000' red = '#cc0000'
# validate the add panel # validate the add panel
if not self.display_name_editor.text_valid: if not self.display_name_editor.text_valid:
self.add_status_label.value = Status("Display name cannot be empty", color=red) self.add_status_label.value = Status(translate('add_account_dialog', "Display name cannot be empty"), color=red)
elif not self.sip_address_editor.text_correct: elif not self.sip_address_editor.text_correct:
self.add_status_label.value = Status("SIP address should be specified as user@domain", color=red) self.add_status_label.value = Status(translate('add_account_dialog', "SIP address should be specified as user@domain"), color=red)
elif not self.sip_address_editor.text_allowed: elif not self.sip_address_editor.text_allowed:
self.add_status_label.value = Status("An account with this SIP address was already added", color=red) self.add_status_label.value = Status(translate('add_account_dialog', "An account with this SIP address was already added"), color=red)
elif not self.password_editor.text_valid: elif not self.password_editor.text_valid:
self.add_status_label.value = Status("Password cannot be empty", color=red) self.add_status_label.value = Status(translate('add_account_dialog', "Password cannot be empty"), color=red)
else: else:
self.add_status_label.value = None self.add_status_label.value = None
# validate the create panel # validate the create panel
if not self.name_editor.text_valid: if not self.name_editor.text_valid:
self.create_status_label.value = Status("Name cannot be empty", color=red) self.create_status_label.value = Status(translate('add_account_dialog', "Name cannot be empty"), color=red)
elif not self.username_editor.text_correct: elif not self.username_editor.text_correct:
self.create_status_label.value = Status("Username should have 5 to 32 characters, start with a letter or non-zero digit, contain only letters, digits or .-_ and end with a letter or digit", color=red) self.create_status_label.value = Status(translate('add_account_dialog', "Username should have 5 to 32 characters, start with a letter or non-zero digit, contain only letters, digits or .-_ and end with a letter or digit"), color=red)
elif not self.username_editor.text_allowed: elif not self.username_editor.text_allowed:
self.create_status_label.value = Status("The username you requested is already taken. Please choose another one and try again.", color=red) self.create_status_label.value = Status(translate('add_account_dialog', "The username you requested is already taken. Please choose another one and try again."), color=red)
elif not self.new_password_editor.text_valid: elif not self.new_password_editor.text_valid:
self.create_status_label.value = Status("Password should contain at least 8 characters", color=red) self.create_status_label.value = Status(translate('add_account_dialog', "Password should contain at least 8 characters"), color=red)
elif not self.verify_password_editor.text_valid: elif not self.verify_password_editor.text_valid:
self.create_status_label.value = Status("Passwords do not match", color=red) self.create_status_label.value = Status(translate('add_account_dialog', "Passwords do not match"), color=red)
elif not self.email_address_editor.text_valid: elif not self.email_address_editor.text_valid:
self.create_status_label.value = Status("E-mail address should be specified as user@domain", color=red) self.create_status_label.value = Status(translate('add_account_dialog', "E-mail address should be specified as user@domain"), color=red)
else: else:
self.create_status_label.value = None self.create_status_label.value = None
# enable the accept button if everything is valid in the current panel # enable the accept button if everything is valid in the current panel
...@@ -488,9 +488,9 @@ class AddAccountDialog(base_class, ui_class, metaclass=QSingleton): ...@@ -488,9 +488,9 @@ class AddAccountDialog(base_class, ui_class, metaclass=QSingleton):
else: else:
call_in_gui_thread(setattr, self.create_status_label, 'value', Status(response_data['error_message'], color=red)) call_in_gui_thread(setattr, self.create_status_label, 'value', Status(response_data['error_message'], color=red))
except (json.decoder.JSONDecodeError, KeyError): except (json.decoder.JSONDecodeError, KeyError):
call_in_gui_thread(setattr, self.create_status_label, 'value', Status('Illegal server response', color=red)) call_in_gui_thread(setattr, self.create_status_label, 'value', Status(translate('add_account_dialog', 'Illegal server response'), color=red))
except urllib.error.URLError as e: except urllib.error.URLError as e:
call_in_gui_thread(setattr, self.create_status_label, 'value', Status('Failed to contact server: %s' % e.reason, color=red)) call_in_gui_thread(setattr, self.create_status_label, 'value', Status(translate('add_account_dialog', 'Failed to contact server: %s') % e.reason, color=red))
finally: finally:
call_in_gui_thread(self.setEnabled, True) call_in_gui_thread(self.setEnabled, True)
...@@ -783,7 +783,7 @@ class ServerToolsWindow(base_class, ui_class, metaclass=QSingleton): ...@@ -783,7 +783,7 @@ class ServerToolsWindow(base_class, ui_class, metaclass=QSingleton):
self._update_navigation_buttons() self._update_navigation_buttons()
def _SH_WebViewTitleChanged(self, title): def _SH_WebViewTitleChanged(self, title):
self.window().setWindowTitle('Blink Server Tools: {}'.format(title)) self.window().setWindowTitle(translate('server_window', 'Blink Server Tools: {}').format(title))
def _SH_ModelChanged(self, parent_index, start, end): def _SH_ModelChanged(self, parent_index, start, end):
menu = self.account_button.menu() menu = self.account_button.menu()
......
This diff is collapsed.
This diff is collapsed.
...@@ -14,6 +14,7 @@ from zope.interface import implementer ...@@ -14,6 +14,7 @@ from zope.interface import implementer
from blink.configuration.settings import BlinkSettings from blink.configuration.settings import BlinkSettings
from blink.resources import Resources from blink.resources import Resources
from blink.sessions import FileTransferDelegate, FileTransferModel from blink.sessions import FileTransferDelegate, FileTransferModel
from blink.util import translate
from blink.widgets.util import ContextMenuActions from blink.widgets.util import ContextMenuActions
...@@ -38,13 +39,13 @@ class FileTransferWindow(base_class, ui_class): ...@@ -38,13 +39,13 @@ class FileTransferWindow(base_class, ui_class):
self.context_menu = QMenu(self.listview) self.context_menu = QMenu(self.listview)
self.actions = ContextMenuActions() self.actions = ContextMenuActions()
self.actions.open_file = QAction("Open", self, triggered=self._AH_OpenFile) self.actions.open_file = QAction(translate('filetransfer_window', "Open"), self, triggered=self._AH_OpenFile)
self.actions.open_file_folder = QAction("Open File Folder", self, triggered=self._AH_OpenFileFolder) self.actions.open_file_folder = QAction(translate('filetransfer_window', "Open File Folder"), self, triggered=self._AH_OpenFileFolder)
self.actions.cancel_transfer = QAction("Cancel", self, triggered=self._AH_CancelTransfer) self.actions.cancel_transfer = QAction(translate('filetransfer_window', "Cancel"), self, triggered=self._AH_CancelTransfer)
self.actions.retry_transfer = QAction("Retry", self, triggered=self._AH_RetryTransfer) self.actions.retry_transfer = QAction(translate('filetransfer_window', "Retry"), self, triggered=self._AH_RetryTransfer)
self.actions.remove_entry = QAction("Remove From List", self, triggered=self._AH_RemoveEntry) self.actions.remove_entry = QAction(translate('filetransfer_window', "Remove From List"), self, triggered=self._AH_RemoveEntry)
self.actions.open_downloads_folder = QAction("Open Transfers Folder", self, triggered=self._AH_OpenTransfersFolder) self.actions.open_downloads_folder = QAction(translate('filetransfer_window', "Open Transfers Folder"), self, triggered=self._AH_OpenTransfersFolder)
self.actions.clear_list = QAction("Clear List", self, triggered=self._AH_ClearList) self.actions.clear_list = QAction(translate('filetransfer_window', "Clear List"), self, triggered=self._AH_ClearList)
self.model.itemAdded.connect(self.update_status) self.model.itemAdded.connect(self.update_status)
self.model.itemRemoved.connect(self.update_status) self.model.itemRemoved.connect(self.update_status)
...@@ -66,9 +67,9 @@ class FileTransferWindow(base_class, ui_class): ...@@ -66,9 +67,9 @@ class FileTransferWindow(base_class, ui_class):
def update_status(self): def update_status(self):
total = len(self.model.items) total = len(self.model.items)
active = len([item for item in self.model.items if not item.ended]) active = len([item for item in self.model.items if not item.ended])
text = '%d %s' % (total, 'transfer' if total == 1 else 'transfers') text = '%d %s' % (total, translate('filetransfer_window', 'transfer') if total == 1 else translate('filetransfer_window', 'transfers'))
if active > 0: if active > 0:
text += ' (%d active)' % active text += translate('filetransfer_window', ' (%d active)') % active
self.status_label.setText(text) self.status_label.setText(text)
def handle_notification(self, notification): def handle_notification(self, notification):
......
...@@ -24,7 +24,7 @@ from blink.configuration.settings import BlinkSettings ...@@ -24,7 +24,7 @@ from blink.configuration.settings import BlinkSettings
from blink.logging import MessagingTrace as log from blink.logging import MessagingTrace as log
from blink.messages import BlinkMessage from blink.messages import BlinkMessage
from blink.resources import ApplicationData, Resources from blink.resources import ApplicationData, Resources
from blink.util import run_in_gui_thread from blink.util import run_in_gui_thread, translate
import traceback import traceback
from sqlobject import SQLObject, StringCol, DateTimeCol, IntCol, UnicodeCol, DatabaseIndex from sqlobject import SQLObject, StringCol, DateTimeCol, IntCol, UnicodeCol, DatabaseIndex
...@@ -587,15 +587,15 @@ class HistoryEntry(object): ...@@ -587,15 +587,15 @@ class HistoryEntry(object):
today = date.today() today = date.today()
days = (today - call_date).days days = (today - call_date).days
if call_date == today: if call_date == today:
result += call_time.strftime(" at %H:%M") result += call_time.strftime(translate("history", " at %H:%M"))
elif days == 1: elif days == 1:
result += call_time.strftime(" Yesterday at %H:%M") result += call_time.strftime(translate("history", " Yesterday at %H:%M"))
elif days < 7: elif days < 7:
result += call_time.strftime(" on %A") result += call_time.strftime(translate("history", " on %A"))
elif call_date.year == today.year: elif call_date.year == today.year:
result += call_time.strftime(" on %B %d") result += call_time.strftime(translate("history", " on %B %d"))
else: else:
result += call_time.strftime(" on %Y-%m-%d") result += call_time.strftime(translate("history", " on %Y-%m-%d"))
if self.duration: if self.duration:
seconds = int(self.duration.total_seconds()) seconds = int(self.duration.total_seconds())
if seconds >= 3600: if seconds >= 3600:
......
This diff is collapsed.
...@@ -41,7 +41,7 @@ from sipsimple.util import ISOTimestamp ...@@ -41,7 +41,7 @@ from sipsimple.util import ISOTimestamp
from blink.logging import MessagingTrace as log from blink.logging import MessagingTrace as log
from blink.resources import Resources from blink.resources import Resources
from blink.sessions import SessionManager, StreamDescription, IncomingDialogBase from blink.sessions import SessionManager, StreamDescription, IncomingDialogBase
from blink.util import run_in_gui_thread from blink.util import run_in_gui_thread, translate
__all__ = ['MessageManager', 'BlinkMessage'] __all__ = ['MessageManager', 'BlinkMessage']
...@@ -60,7 +60,7 @@ class GeneratePGPKeyDialog(IncomingDialogBase, ui_class): ...@@ -60,7 +60,7 @@ class GeneratePGPKeyDialog(IncomingDialogBase, ui_class):
self.setupUi(self) self.setupUi(self)
self.slot = None self.slot = None
self.generate_button = self.dialog_button_box.addButton("Generate", QDialogButtonBox.AcceptRole) self.generate_button = self.dialog_button_box.addButton(translate("generate_pgp_key_dialog", "Generate"), QDialogButtonBox.AcceptRole)
self.generate_button.setIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton)) self.generate_button.setIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton))
def show(self, activate=True): def show(self, activate=True):
...@@ -136,7 +136,7 @@ class ImportDialog(IncomingDialogBase, ui_class): ...@@ -136,7 +136,7 @@ class ImportDialog(IncomingDialogBase, ui_class):
self.setupUi(self) self.setupUi(self)
self.slot = None self.slot = None
self.import_button = self.dialog_button_box.addButton("Import", QDialogButtonBox.AcceptRole) self.import_button = self.dialog_button_box.addButton(translate("import_key_dialog", "Import"), QDialogButtonBox.AcceptRole)
self.import_button.setIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton)) self.import_button.setIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton))
self.import_button.setEnabled(False) self.import_button.setEnabled(False)
...@@ -232,7 +232,7 @@ class ExportDialog(IncomingDialogBase, ui_class): ...@@ -232,7 +232,7 @@ class ExportDialog(IncomingDialogBase, ui_class):
self.setupUi(self) self.setupUi(self)
self.slot = None self.slot = None
self.export_button = self.dialog_button_box.addButton("Export", QDialogButtonBox.AcceptRole) self.export_button = self.dialog_button_box.addButton(translate("export_key_dialog", "Export"), QDialogButtonBox.AcceptRole)
self.export_button.setIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton)) self.export_button.setIcon(QApplication.style().standardIcon(QStyle.SP_DialogApplyButton))
self.export_button.setEnabled(False) self.export_button.setEnabled(False)
......
This diff is collapsed.
...@@ -23,6 +23,7 @@ from sipsimple.threading import run_in_thread ...@@ -23,6 +23,7 @@ from sipsimple.threading import run_in_thread
from blink.configuration.settings import BlinkSettings from blink.configuration.settings import BlinkSettings
from blink.resources import Resources from blink.resources import Resources
from blink.screensharing.vncclient import ServerDefault, TrueColor, HighColor, LowColor from blink.screensharing.vncclient import ServerDefault, TrueColor, HighColor, LowColor
from blink.util import translate
__all__ = ['ScreensharingWindow', 'VNCViewer'] __all__ = ['ScreensharingWindow', 'VNCViewer']
...@@ -401,7 +402,7 @@ class ScreensharingDialog(base_class, ui_class): ...@@ -401,7 +402,7 @@ class ScreensharingDialog(base_class, ui_class):
return False return False
def get_credentials(self): def get_credentials(self):
self.message_label.setText('Screen sharing requires authentication') self.message_label.setText(translate('vnc_viewer', 'Screen sharing requires authentication'))
self.username_label.show() self.username_label.show()
self.username_editor.show() self.username_editor.show()
self.username_editor.clear() self.username_editor.clear()
...@@ -413,7 +414,7 @@ class ScreensharingDialog(base_class, ui_class): ...@@ -413,7 +414,7 @@ class ScreensharingDialog(base_class, ui_class):
return (self.username_editor.text(), self.password_editor.text()) if result == self.Accepted else (None, None) return (self.username_editor.text(), self.password_editor.text()) if result == self.Accepted else (None, None)
def get_password(self): def get_password(self):
self.message_label.setText('Screen sharing requires a password') self.message_label.setText(translate('vnc_viewer', 'Screen sharing requires a password'))
self.username_label.hide() self.username_label.hide()
self.username_editor.hide() self.username_editor.hide()
self.username_editor.clear() self.username_editor.clear()
...@@ -493,7 +494,7 @@ class ScreensharingToolbox(base_class, ui_class): ...@@ -493,7 +494,7 @@ class ScreensharingToolbox(base_class, ui_class):
self.close_button.setDefaultAction(self.close_action) self.close_button.setDefaultAction(self.close_action)
self.color_depth_button.clear() self.color_depth_button.clear()
self.color_depth_button.addItem('Default Color Depth', ServerDefault) self.color_depth_button.addItem(translate('vnc_viewer', 'Default Color Depth'), ServerDefault)
self.color_depth_button.addItem('TrueColor (24 bits)', TrueColor) self.color_depth_button.addItem('TrueColor (24 bits)', TrueColor)
self.color_depth_button.addItem('HighColor (16 bits)', HighColor) self.color_depth_button.addItem('HighColor (16 bits)', HighColor)
self.color_depth_button.addItem('LowColor (8 bits)', LowColor) self.color_depth_button.addItem('LowColor (8 bits)', LowColor)
...@@ -593,13 +594,13 @@ class ScreensharingWindow(base_class, ui_class): ...@@ -593,13 +594,13 @@ class ScreensharingWindow(base_class, ui_class):
self.fullscreen_button.setDefaultAction(self.fullscreen_action) self.fullscreen_button.setDefaultAction(self.fullscreen_action)
self.color_depth_button.clear() self.color_depth_button.clear()
self.color_depth_button.addItem('Default Color Depth', ServerDefault) self.color_depth_button.addItem(translate('vnc_viewer', 'Default Color Depth'), ServerDefault)
self.color_depth_button.addItem('TrueColor (24 bits)', TrueColor) self.color_depth_button.addItem('TrueColor (24 bits)', TrueColor)
self.color_depth_button.addItem('HighColor (16 bits)', HighColor) self.color_depth_button.addItem('HighColor (16 bits)', HighColor)
self.color_depth_button.addItem('LowColor (8 bits)', LowColor) self.color_depth_button.addItem('LowColor (8 bits)', LowColor)
self.screenshot_button_menu = QMenu(self) self.screenshot_button_menu = QMenu(self)
self.screenshot_button_menu.addAction('Open screenshots folder', self._SH_ScreenshotsFolderActionTriggered) self.screenshot_button_menu.addAction(translate('vnc_viewer', 'Open screenshots folder'), self._SH_ScreenshotsFolderActionTriggered)
def closeEvent(self, event): def closeEvent(self, event):
super(ScreensharingWindow, self).closeEvent(event) super(ScreensharingWindow, self).closeEvent(event)
......
This diff is collapsed.
from PyQt5.QtCore import Qt, QLineF, QPointF, QRectF, QSize, QTimer, pyqtSignal from PyQt5.QtCore import Qt, QCoreApplication, QLineF, QPointF, QRectF, QSize, QTimer, pyqtSignal, QT_TRANSLATE_NOOP
from PyQt5.QtGui import QBrush, QColor, QLinearGradient, QIcon, QPainter, QPainterPath, QPalette, QPen, QPixmap, QPolygonF from PyQt5.QtGui import QBrush, QColor, QLinearGradient, QIcon, QPainter, QPainterPath, QPalette, QPen, QPixmap, QPolygonF
from PyQt5.QtWidgets import QAction, QCommonStyle, QMenu, QPushButton, QStyle, QStyleOptionToolButton, QStylePainter, QToolButton from PyQt5.QtWidgets import QAction, QCommonStyle, QMenu, QPushButton, QStyle, QStyleOptionToolButton, QStylePainter, QToolButton
...@@ -10,6 +10,8 @@ from blink.widgets.color import ColorScheme, ColorUtils, ColorHelperMixin ...@@ -10,6 +10,8 @@ from blink.widgets.color import ColorScheme, ColorUtils, ColorHelperMixin
__all__ = ['ToolButton', 'ConferenceButton', 'StreamButton', 'SegmentButton', 'SingleSegment', 'LeftSegment', 'MiddleSegment', 'RightSegment', __all__ = ['ToolButton', 'ConferenceButton', 'StreamButton', 'SegmentButton', 'SingleSegment', 'LeftSegment', 'MiddleSegment', 'RightSegment',
'RecordButton', 'SwitchViewButton', 'StateButton', 'AccountState'] 'RecordButton', 'SwitchViewButton', 'StateButton', 'AccountState']
translate = QCoreApplication.translate
class ToolButton(QToolButton): class ToolButton(QToolButton):
"""A custom QToolButton that doesn't show a menu indicator arrow""" """A custom QToolButton that doesn't show a menu indicator arrow"""
...@@ -28,8 +30,8 @@ class ConferenceButton(ToolButton): ...@@ -28,8 +30,8 @@ class ConferenceButton(ToolButton):
def __init__(self, parent=None): def __init__(self, parent=None):
super(ConferenceButton, self).__init__(parent) super(ConferenceButton, self).__init__(parent)
self.make_conference_action = QAction('Conference all single sessions', self, triggered=self.makeConference.emit) self.make_conference_action = QAction(translate('conference_button', 'Conference all single sessions'), self, triggered=self.makeConference.emit)
self.break_conference_action = QAction('Break selected conference', self, triggered=self.breakConference.emit) self.break_conference_action = QAction(translate('conference_button', 'Break selected conference'), self, triggered=self.breakConference.emit)
self.toggled.connect(self._SH_Toggled) self.toggled.connect(self._SH_Toggled)
self.addAction(self.make_conference_action) self.addAction(self.make_conference_action)
...@@ -259,8 +261,8 @@ class SwitchViewButton(QPushButton): ...@@ -259,8 +261,8 @@ class SwitchViewButton(QPushButton):
viewChanged = pyqtSignal(int) viewChanged = pyqtSignal(int)
button_text = {ContactView: 'Switch to Calls', SessionView: 'Switch to Contacts'} button_text = {ContactView: QT_TRANSLATE_NOOP('switch_view_button', 'Switch to Calls'), SessionView: QT_TRANSLATE_NOOP('switch_view_button', 'Switch to Contacts')}
button_dnd_text = {ContactView: 'Drag here to add to a conference', SessionView: 'Drag here to go back to contacts'} button_dnd_text = {ContactView: QT_TRANSLATE_NOOP('switch_view_button', 'Drag here to add to a conference'), SessionView: QT_TRANSLATE_NOOP('switch_view_button', 'Drag here to go back to contacts')}
dnd_style_sheet1 = """ dnd_style_sheet1 = """
QPushButton { QPushButton {
...@@ -307,7 +309,7 @@ class SwitchViewButton(QPushButton): ...@@ -307,7 +309,7 @@ class SwitchViewButton(QPushButton):
text = self.button_dnd_text[value] text = self.button_dnd_text[value]
else: else:
text = self.button_text[value] text = self.button_text[value]
self.setText(text) self.setText(translate('switch_view_button', text))
self.viewChanged.emit(value) self.viewChanged.emit(value)
view = property(_get_view, _set_view) view = property(_get_view, _set_view)
...@@ -324,11 +326,11 @@ class SwitchViewButton(QPushButton): ...@@ -324,11 +326,11 @@ class SwitchViewButton(QPushButton):
self.dnd_timer.phase = 0 self.dnd_timer.phase = 0
self.original_height = self.height() self.original_height = self.height()
self.setStyleSheet(self.dnd_style_sheet1) self.setStyleSheet(self.dnd_style_sheet1)
self.setText(self.button_dnd_text[self.view]) self.setText(translate('switch_view_button', self.button_dnd_text[self.view]))
self.setFixedHeight(40) self.setFixedHeight(40)
else: else:
self.setStyleSheet('') self.setStyleSheet('')
self.setText(self.button_text[self.view]) self.setText(translate('switch_view_button', self.button_text[self.view]))
self.setFixedHeight(self.original_height) self.setFixedHeight(self.original_height)
dnd_active = property(_get_dnd_active, _set_dnd_active) dnd_active = property(_get_dnd_active, _set_dnd_active)
...@@ -662,10 +664,10 @@ class PresenceState(object): ...@@ -662,10 +664,10 @@ class PresenceState(object):
class AccountState(StateButton): class AccountState(StateButton):
Invisible = PresenceState('Invisible', '#efedeb', Resources.get('icons/state-invisible.svg')) Invisible = PresenceState(QT_TRANSLATE_NOOP('presence_state', 'Invisible'), '#efedeb', Resources.get('icons/state-invisible.svg'))
Available = PresenceState('Available', '#00ff00', Resources.get('icons/state-available.svg')) Available = PresenceState(QT_TRANSLATE_NOOP('presence_state', 'Available'), '#00ff00', Resources.get('icons/state-available.svg'))
Away = PresenceState('Away', '#ffff00', Resources.get('icons/state-away.svg')) Away = PresenceState(QT_TRANSLATE_NOOP('presence_state', 'Away'), '#ffff00', Resources.get('icons/state-away.svg'))
Busy = PresenceState('Busy', '#ff0000', Resources.get('icons/state-busy.svg')) Busy = PresenceState(QT_TRANSLATE_NOOP('presence_state', 'Busy'), '#ff0000', Resources.get('icons/state-busy.svg'))
stateChanged = pyqtSignal() stateChanged = pyqtSignal()
...@@ -675,7 +677,7 @@ class AccountState(StateButton): ...@@ -675,7 +677,7 @@ class AccountState(StateButton):
super(AccountState, self).__init__(parent) super(AccountState, self).__init__(parent)
menu = QMenu(self) menu = QMenu(self)
for state in (self.Available, self.Away, self.Busy, self.Invisible): for state in (self.Available, self.Away, self.Busy, self.Invisible):
action = menu.addAction(QIcon(state.icon), state.name) action = menu.addAction(QIcon(state.icon), translate('presence_state', state.name))
action.state = state action.state = state
action.note = None action.note = None
menu.addSeparator() menu.addSeparator()
......
...@@ -11,6 +11,7 @@ from application.python.types import MarkerType ...@@ -11,6 +11,7 @@ from application.python.types import MarkerType
from sipsimple.configuration.datatypes import Path from sipsimple.configuration.datatypes import Path
from blink.resources import IconManager from blink.resources import IconManager
from blink.util import translate
from blink.widgets.color import ColorHelperMixin from blink.widgets.color import ColorHelperMixin
from blink.widgets.util import QtDynamicProperty, ContextMenuActions from blink.widgets.util import QtDynamicProperty, ContextMenuActions
...@@ -27,8 +28,8 @@ class IconSelector(QLabel): ...@@ -27,8 +28,8 @@ class IconSelector(QLabel):
def __init__(self, parent=None): def __init__(self, parent=None):
super(IconSelector, self).__init__(parent) super(IconSelector, self).__init__(parent)
self.actions = ContextMenuActions() self.actions = ContextMenuActions()
self.actions.select_icon = QAction('Select icon...', self, triggered=self._SH_ChangeIconActionTriggered) self.actions.select_icon = QAction(translate('icon_selector', 'Select icon...'), self, triggered=self._SH_ChangeIconActionTriggered)
self.actions.remove_icon = QAction('Use contact provided icon', self, triggered=self._SH_RemoveIconActionTriggered) self.actions.remove_icon = QAction(translate('icon_selector', 'Use contact provided icon'), self, triggered=self._SH_RemoveIconActionTriggered)
self.icon_size = 48 self.icon_size = 48
self.default_icon = None self.default_icon = None
self.contact_icon = None self.contact_icon = None
...@@ -107,7 +108,7 @@ class IconSelector(QLabel): ...@@ -107,7 +108,7 @@ class IconSelector(QLabel):
super(IconSelector, self).mouseReleaseEvent(event) super(IconSelector, self).mouseReleaseEvent(event)
def _SH_ChangeIconActionTriggered(self): def _SH_ChangeIconActionTriggered(self):
filename = QFileDialog.getOpenFileName(self, 'Select Icon', self.last_icon_directory, "Images (*.png *.tiff *.jpg *.xmp *.svg)")[0] filename = QFileDialog.getOpenFileName(self, translate('icon_selector', 'Select Icon'), self.last_icon_directory, "Images (*.png *.tiff *.jpg *.xmp *.svg)")[0]
if filename: if filename:
self.filename = filename self.filename = filename
......
...@@ -6,6 +6,7 @@ from PyQt5.QtGui import QPainter, QPalette, QPixmap ...@@ -6,6 +6,7 @@ from PyQt5.QtGui import QPainter, QPalette, QPixmap
from PyQt5.QtWidgets import QAbstractButton, QLineEdit, QBoxLayout, QHBoxLayout, QLabel, QLayout, QSizePolicy, QSpacerItem, QStyle, QStyleOptionFrame, QWidget from PyQt5.QtWidgets import QAbstractButton, QLineEdit, QBoxLayout, QHBoxLayout, QLabel, QLayout, QSizePolicy, QSpacerItem, QStyle, QStyleOptionFrame, QWidget
from blink.resources import Resources from blink.resources import Resources
from blink.util import translate
from blink.widgets.util import QtDynamicProperty from blink.widgets.util import QtDynamicProperty
...@@ -274,7 +275,7 @@ class SearchBox(LineEdit): ...@@ -274,7 +275,7 @@ class SearchBox(LineEdit):
self.clear_button.hide() self.clear_button.hide()
self.clear_button.clicked.connect(self.clear) self.clear_button.clicked.connect(self.clear)
self.textChanged.connect(self._SH_TextChanged) self.textChanged.connect(self._SH_TextChanged)
self.inactiveText = "Search" self.inactiveText = translate('search_box', "Search")
def keyPressEvent(self, event): def keyPressEvent(self, event):
if event.key() == Qt.Key_Escape: if event.key() == Qt.Key_Escape:
......
...@@ -6,6 +6,7 @@ from PyQt5.QtCore import Qt, pyqtSignal ...@@ -6,6 +6,7 @@ from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtWidgets import QStyle, QStyleOption, QStylePainter from PyQt5.QtWidgets import QStyle, QStyleOption, QStylePainter
from blink.resources import Resources from blink.resources import Resources
from blink.util import translate
from blink.sessions import SMPVerification from blink.sessions import SMPVerification
...@@ -56,7 +57,7 @@ class OTRWidget(base_class, ui_class): ...@@ -56,7 +57,7 @@ class OTRWidget(base_class, ui_class):
@peer_verified.setter @peer_verified.setter
def peer_verified(self, verified): def peer_verified(self, verified):
self.__dict__['peer_verified'] = verified self.__dict__['peer_verified'] = verified
self.validate_button.setText('Invalidate' if verified else 'Validate') self.validate_button.setText(translate('otr_widget', 'Invalidate') if verified else translate('otr_widget', 'Validate'))
self.validate_button.setChecked(verified) self.validate_button.setChecked(verified)
self.validate_button.setEnabled(verified or self.verification_stack.currentWidget() is not self.smp_panel or self.smp_status is SMPVerification.Succeeded) self.validate_button.setEnabled(verified or self.verification_stack.currentWidget() is not self.smp_panel or self.smp_status is SMPVerification.Succeeded)
self.peer_fingerprint_value.setStyleSheet('QLabel {{ color: {}; }}'.format(self.color_table['green'] if verified else self.color_table['orange'])) self.peer_fingerprint_value.setStyleSheet('QLabel {{ color: {}; }}'.format(self.color_table['green'] if verified else self.color_table['orange']))
...@@ -93,11 +94,11 @@ class OTRWidget(base_class, ui_class): ...@@ -93,11 +94,11 @@ class OTRWidget(base_class, ui_class):
@property @property
def smp_status_text(self): def smp_status_text(self):
if self.peer_verified: if self.peer_verified:
return '<span style="color: {[green]};">Verified</span>'.format(self.color_table) return translate('otr_widget', '<span style="color: {[green]};">Verified</span>').format(self.color_table)
elif self.smp_status is SMPVerification.Succeeded: elif self.smp_status is SMPVerification.Succeeded:
return '<span style="color: {[green]};">Succeeded</span>'.format(self.color_table) return translate('otr_widget', '<span style="color: {[green]};">Succeeded</span>').format(self.color_table)
elif self.smp_status is SMPVerification.Failed: elif self.smp_status is SMPVerification.Failed:
return '<span style="color: {[orange]};">Failed</span>'.format(self.color_table) return translate('otr_widget', '<span style="color: {[orange]};">Failed</span>').format(self.color_table)
else: else:
return '{}'.format(self.smp_status.value) return '{}'.format(self.smp_status.value)
......
...@@ -4,6 +4,7 @@ from PyQt5.QtCore import Qt, pyqtSignal ...@@ -4,6 +4,7 @@ from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtWidgets import QStyle, QStyleOption, QStylePainter from PyQt5.QtWidgets import QStyle, QStyleOption, QStylePainter
from blink.resources import Resources from blink.resources import Resources
from blink.util import translate
__all__ = ['ZRTPWidget'] __all__ = ['ZRTPWidget']
...@@ -44,10 +45,10 @@ class ZRTPWidget(base_class, ui_class): ...@@ -44,10 +45,10 @@ class ZRTPWidget(base_class, ui_class):
self.__dict__['peer_verified'] = verified self.__dict__['peer_verified'] = verified
if verified: if verified:
self.validate_button.setText('Invalidate') self.validate_button.setText('Invalidate')
self.status_value.setText('<span style="color: hsv(100, 85%, 100%);">Verified</span>') self.status_value.setText(translate('zrtp_widget', '<span style="color: hsv(100, 85%, 100%);">Verified</span>'))
else: else:
self.validate_button.setText('Validate') self.validate_button.setText('Validate')
self.status_value.setText('<span style="color: hsv(20, 85%, 100%);">Not verified</span>') self.status_value.setText(translate('zrtp_widget', '<span style="color: hsv(20, 85%, 100%);">Not verified</span>'))
self.validate_button.setChecked(verified) self.validate_button.setChecked(verified)
peer_verified = property(_get_peer_verified, _set_peer_verified) peer_verified = property(_get_peer_verified, _set_peer_verified)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment