Add system translations

Items like dialog box buttons were not localised. This loads the default
qt localisation, and also unloads the old localisation on locale change.
Still needs to be adjusted for frozen.

Addresses Bitmessage#737
This commit is contained in:
mailchuck 2015-12-15 04:24:35 +01:00 committed by Peter Surda
parent 7ef94b446d
commit eb35f35b83

View File

@ -69,11 +69,27 @@ def _translate(context, text):
return QtGui.QApplication.translate(context, text) return QtGui.QApplication.translate(context, text)
def change_translation(locale): def change_translation(locale):
global qtranslator global qmytranslator, qsystranslator
qtranslator = QtCore.QTranslator() try:
if not qmytranslator.isEmpty():
QtGui.QApplication.removeTranslator(qmytranslator)
except:
pass
try:
if not qsystranslator.isEmpty():
QtGui.QApplication.removeTranslator(qsystranslator)
except:
pass
qmytranslator = QtCore.QTranslator()
translationpath = os.path.join (shared.codePath(), 'translations', 'bitmessage_' + locale) translationpath = os.path.join (shared.codePath(), 'translations', 'bitmessage_' + locale)
qtranslator.load(translationpath) qmytranslator.load(translationpath)
QtGui.QApplication.installTranslator(qtranslator) QtGui.QApplication.installTranslator(qmytranslator)
qsystranslator = QtCore.QTranslator()
translationpath = os.path.join (str(QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)), 'qt_' + locale)
qsystranslator.load(translationpath)
QtGui.QApplication.installTranslator(qsystranslator)
class MyForm(settingsmixin.SMainWindow): class MyForm(settingsmixin.SMainWindow):