Translation fixes
- locale name is properly normalised rather than simply changing the string - translations now support plurals/paucals - networkstatus updated
This commit is contained in:
parent
9e10d714aa
commit
c29f266020
|
@ -71,8 +71,11 @@ from dialogs import AddAddressDialog
|
||||||
from class_objectHashHolder import objectHashHolder
|
from class_objectHashHolder import objectHashHolder
|
||||||
from class_singleWorker import singleWorker
|
from class_singleWorker import singleWorker
|
||||||
|
|
||||||
def _translate(context, text):
|
def _translate(context, text, number = None):
|
||||||
return QtGui.QApplication.translate(context, text)
|
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):
|
def change_translation(locale):
|
||||||
global qmytranslator, qsystranslator
|
global qmytranslator, qsystranslator
|
||||||
|
@ -100,16 +103,11 @@ def change_translation(locale):
|
||||||
qsystranslator.load(translationpath)
|
qsystranslator.load(translationpath)
|
||||||
QtGui.QApplication.installTranslator(qsystranslator)
|
QtGui.QApplication.installTranslator(qsystranslator)
|
||||||
|
|
||||||
lang = l10n.getTranslationLanguage()
|
lang = pythonlocale.normalize(l10n.getTranslationLanguage())
|
||||||
if "_" not in lang:
|
|
||||||
lang += "_" + lang.upper()
|
|
||||||
if ".utf8" not in lang.lower():
|
|
||||||
lang += ".utf8"
|
|
||||||
try:
|
try:
|
||||||
pythonlocale.setlocale(pythonlocale.LC_ALL, lang)
|
pythonlocale.setlocale(pythonlocale.LC_ALL, lang)
|
||||||
except:
|
except:
|
||||||
logger.error("Failed to set locale to %s", lang)
|
logger.error("Failed to set locale to %s", lang, exc_info=True)
|
||||||
pass
|
|
||||||
|
|
||||||
class MyForm(settingsmixin.SMainWindow):
|
class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
||||||
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.runEveryTwoSeconds)
|
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.runEveryTwoSeconds)
|
||||||
|
|
||||||
def formatBytes(self, num):
|
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:
|
if num < 1000.0:
|
||||||
return "%3.0f %s" % (num, x)
|
return "%3.0f %s" % (num, x)
|
||||||
num /= 1000.0
|
num /= 1000.0
|
||||||
|
@ -45,20 +45,23 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
||||||
num /= 1000
|
num /= 1000
|
||||||
return "%4.0f kB" % num
|
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):
|
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(
|
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):
|
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(
|
self.labelBroadcastCount.setText(_translate(
|
||||||
"networkstatus", "Processed %1 broadcast messages.").arg(str(shared.numberOfBroadcastsProcessed)))
|
"networkstatus", "Processed %n broadcast message(s).", shared.numberOfBroadcastsProcessed))
|
||||||
|
|
||||||
def updateNumberOfPubkeysProcessed(self):
|
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(
|
self.labelPubkeyCount.setText(_translate(
|
||||||
"networkstatus", "Processed %1 public keys.").arg(str(shared.numberOfPubkeysProcessed)))
|
"networkstatus", "Processed %n public key(s).", shared.numberOfPubkeysProcessed))
|
||||||
|
|
||||||
def updateNumberOfBytes(self):
|
def updateNumberOfBytes(self):
|
||||||
"""
|
"""
|
||||||
|
|
11
src/tr.py
11
src/tr.py
|
@ -12,10 +12,10 @@ class translateClass:
|
||||||
else:
|
else:
|
||||||
return self.text
|
return self.text
|
||||||
|
|
||||||
def _translate(context, text):
|
def _translate(context, text, n = None):
|
||||||
return translateText(context, text)
|
return translateText(context, text, n)
|
||||||
|
|
||||||
def translateText(context, text):
|
def translateText(context, text, n = None):
|
||||||
if not shared.safeConfigGetBoolean('bitmessagesettings', 'daemon'):
|
if not shared.safeConfigGetBoolean('bitmessagesettings', 'daemon'):
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtCore, QtGui
|
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 '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
|
print 'Error message:', err
|
||||||
os._exit(0)
|
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:
|
else:
|
||||||
if '%' in text:
|
if '%' in text:
|
||||||
return translateClass(context, text.replace('%','',1))
|
return translateClass(context, text.replace('%','',1))
|
||||||
|
|
Reference in New Issue
Block a user