From eb35f35b834223ce6a3cf43969753045facd8991 Mon Sep 17 00:00:00 2001 From: mailchuck Date: Tue, 15 Dec 2015 04:24:35 +0100 Subject: [PATCH] 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 --- src/bitmessageqt/__init__.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index b3f700b5..5831987c 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -69,11 +69,27 @@ def _translate(context, text): return QtGui.QApplication.translate(context, text) def change_translation(locale): - global qtranslator - qtranslator = QtCore.QTranslator() + global qmytranslator, qsystranslator + 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) - qtranslator.load(translationpath) - QtGui.QApplication.installTranslator(qtranslator) + qmytranslator.load(translationpath) + 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):