V0.6 #852
|
@ -71,8 +71,11 @@ from dialogs import AddAddressDialog
|
|||
from class_objectHashHolder import objectHashHolder
|
||||
from class_singleWorker import singleWorker
|
||||
|
||||
def _translate(context, text):
|
||||
return QtGui.QApplication.translate(context, text)
|
||||
def _translate(context, text, number = None):
|
||||
if number is None:
|
||||
return QtGui.QApplication.translate(context, text)
|
||||
else:
|
||||
return QtGui.QApplication.translate(context, text, None, QtCore.QCoreApplication.CodecForTr, number)
|
||||
|
||||
def change_translation(locale):
|
||||
global qmytranslator, qsystranslator
|
||||
|
@ -100,16 +103,11 @@ def change_translation(locale):
|
|||
qsystranslator.load(translationpath)
|
||||
QtGui.QApplication.installTranslator(qsystranslator)
|
||||
|
||||
lang = l10n.getTranslationLanguage()
|
||||
if "_" not in lang:
|
||||
lang += "_" + lang.upper()
|
||||
if ".utf8" not in lang.lower():
|
||||
lang += ".utf8"
|
||||
lang = pythonlocale.normalize(l10n.getTranslationLanguage())
|
||||
try:
|
||||
pythonlocale.setlocale(pythonlocale.LC_ALL, lang)
|
||||
except:
|
||||
logger.error("Failed to set locale to %s", lang)
|
||||
pass
|
||||
logger.error("Failed to set locale to %s", lang, exc_info=True)
|
||||
|
||||
class MyForm(settingsmixin.SMainWindow):
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
|||
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.runEveryTwoSeconds)
|
||||
|
||||
def formatBytes(self, num):
|
||||
for x in [_translate("networkstatus", "byte(s)"), "kB", "MB", "GB"]:
|
||||
for x in [_translate("networkstatus", "byte(s)", num), "kB", "MB", "GB"]:
|
||||
if num < 1000.0:
|
||||
return "%3.0f %s" % (num, x)
|
||||
num /= 1000.0
|
||||
|
@ -44,21 +44,24 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
|||
def formatByteRate(self, num):
|
||||
num /= 1000
|
||||
return "%4.0f kB" % num
|
||||
|
||||
def updateNumberOfObjectsToBeSynced(self):
|
||||
self.labelSyncStatus.setText(_translate("networkstatus", "Object(s) to be synced: %n", sum(shared.numberOfObjectsThatWeHaveYetToGetPerPeer.itervalues())))
|
||||
|
||||
def updateNumberOfMessagesProcessed(self):
|
||||
self.labelSyncStatus.setText(_translate("networkstatus", "Objects to be synced: %1").arg(str(sum(shared.numberOfObjectsThatWeHaveYetToGetPerPeer.itervalues()))))
|
||||
self.updateNumberOfObjectsToBeSynced()
|
||||
self.labelMessageCount.setText(_translate(
|
||||
"networkstatus", "Processed %1 person-to-person messages.").arg(str(shared.numberOfMessagesProcessed)))
|
||||
"networkstatus", "Processed %n person-to-person message(s).", shared.numberOfMessagesProcessed))
|
||||
|
||||
def updateNumberOfBroadcastsProcessed(self):
|
||||
self.labelSyncStatus.setText(_translate("networkstatus", "Objects to be synced: %1").arg(str(sum(shared.numberOfObjectsThatWeHaveYetToGetPerPeer.itervalues()))))
|
||||
self.updateNumberOfObjectsToBeSynced()
|
||||
self.labelBroadcastCount.setText(_translate(
|
||||
"networkstatus", "Processed %1 broadcast messages.").arg(str(shared.numberOfBroadcastsProcessed)))
|
||||
"networkstatus", "Processed %n broadcast message(s).", shared.numberOfBroadcastsProcessed))
|
||||
|
||||
def updateNumberOfPubkeysProcessed(self):
|
||||
self.labelSyncStatus.setText(_translate("networkstatus", "Objects to be synced: %1").arg(str(sum(shared.numberOfObjectsThatWeHaveYetToGetPerPeer.itervalues()))))
|
||||
self.updateNumberOfObjectsToBeSynced()
|
||||
self.labelPubkeyCount.setText(_translate(
|
||||
"networkstatus", "Processed %1 public keys.").arg(str(shared.numberOfPubkeysProcessed)))
|
||||
"networkstatus", "Processed %n public key(s).", shared.numberOfPubkeysProcessed))
|
||||
|
||||
def updateNumberOfBytes(self):
|
||||
"""
|
||||
|
|
11
src/tr.py
11
src/tr.py
|
@ -12,10 +12,10 @@ class translateClass:
|
|||
else:
|
||||
return self.text
|
||||
|
||||
def _translate(context, text):
|
||||
return translateText(context, text)
|
||||
def _translate(context, text, n = None):
|
||||
return translateText(context, text, n)
|
||||
|
||||
def translateText(context, text):
|
||||
def translateText(context, text, n = None):
|
||||
if not shared.safeConfigGetBoolean('bitmessagesettings', 'daemon'):
|
||||
try:
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
@ -23,7 +23,10 @@ def translateText(context, text):
|
|||
print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
|
||||
print 'Error message:', err
|
||||
os._exit(0)
|
||||
return QtGui.QApplication.translate(context, text)
|
||||
if n is None:
|
||||
return QtGui.QApplication.translate(context, text)
|
||||
else:
|
||||
return QtGui.QApplication.translate(context, text, None, QtCore.QCoreApplication.CodecForTr, n)
|
||||
else:
|
||||
if '%' in text:
|
||||
return translateClass(context, text.replace('%','',1))
|
||||
|
|
Reference in New Issue
Block a user