Marked folder names for translation

This commit is contained in:
Dmitri Bogomolov 2018-02-12 13:21:31 +02:00
parent eb97face61
commit 6bcbad63b9
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

View File

@ -1,12 +1,20 @@
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from string import find, rfind, rstrip, lstrip from string import find, rfind, rstrip, lstrip
from tr import _translate
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from helper_sql import * from helper_sql import *
from utils import * from utils import *
from settingsmixin import SettingsMixin from settingsmixin import SettingsMixin
class AccountMixin (object): # for pylupdate
_translate("MainWindow", "inbox")
_translate("MainWindow", "new")
_translate("MainWindow", "sent")
_translate("MainWindow", "trash")
class AccountMixin(object):
ALL = 0 ALL = 0
NORMAL = 1 NORMAL = 1
CHAN = 2 CHAN = 2
@ -97,7 +105,8 @@ class AccountMixin (object):
retval, = row retval, = row
retval = unicode(retval, 'utf-8') retval = unicode(retval, 'utf-8')
elif self.address is None or self.type == AccountMixin.ALL: elif self.address is None or self.type == AccountMixin.ALL:
return unicode(str(QtGui.QApplication.translate("MainWindow", "All accounts")), 'utf-8') return unicode(
str(_translate("MainWindow", "All accounts")), 'utf-8')
if retval is None: if retval is None:
return unicode(self.address, 'utf-8') return unicode(self.address, 'utf-8')
else: else:
@ -115,17 +124,16 @@ class Ui_FolderWidget(QtGui.QTreeWidgetItem, AccountMixin):
def setFolderName(self, fname): def setFolderName(self, fname):
self.folderName = str(fname) self.folderName = str(fname)
def data(self, column, role): def data(self, column, role):
if column == 0: if column == 0:
if role == QtCore.Qt.DisplayRole: if role == QtCore.Qt.DisplayRole:
return QtGui.QApplication.translate("MainWindow", self.folderName) + (" (" + str(self.unreadCount) + ")" if self.unreadCount > 0 else "") return _translate("MainWindow", self.folderName) + (
elif role == QtCore.Qt.EditRole: " (" + str(self.unreadCount) + ")"
return QtGui.QApplication.translate("MainWindow", self.folderName) if self.unreadCount > 0 else ""
elif role == QtCore.Qt.ToolTipRole: )
return QtGui.QApplication.translate("MainWindow", self.folderName) elif role in (QtCore.Qt.EditRole, QtCore.Qt.ToolTipRole):
elif role == QtCore.Qt.DecorationRole: return _translate("MainWindow", self.folderName)
pass
elif role == QtCore.Qt.FontRole: elif role == QtCore.Qt.FontRole:
font = QtGui.QFont() font = QtGui.QFont()
font.setBold(self.unreadCount > 0) font.setBold(self.unreadCount > 0)
@ -166,16 +174,19 @@ class Ui_AddressWidget(QtGui.QTreeWidgetItem, AccountMixin, SettingsMixin):
self.setEnabled(enabled) self.setEnabled(enabled)
self.setUnreadCount(unreadCount) self.setUnreadCount(unreadCount)
self.setType() self.setType()
def _getLabel(self): def _getLabel(self):
if self.address is None: if self.address is None:
return unicode(QtGui.QApplication.translate("MainWindow", "All accounts").toUtf8(), 'utf-8', 'ignore') return unicode(_translate(
"MainWindow", "All accounts").toUtf8(), 'utf-8', 'ignore')
else: else:
try: try:
return unicode(BMConfigParser().get(self.address, 'label'), 'utf-8', 'ignore') return unicode(
BMConfigParser().get(self.address, 'label'),
'utf-8', 'ignore')
except: except:
return unicode(self.address, 'utf-8') return unicode(self.address, 'utf-8')
def _getAddressBracket(self, unreadCount = False): def _getAddressBracket(self, unreadCount = False):
ret = "" ret = ""
if unreadCount: if unreadCount: