1
0
Fork 0
mirror of https://github.com/Athemis/PyDSF.git synced 2025-04-05 14:46:03 +00:00

Fix loading of translations

This commit is contained in:
Alexander Minges 2015-07-08 12:54:51 +02:00
parent 750a9b7157
commit e1b0edd292
2 changed files with 14 additions and 10 deletions

11
main.py
View file

@ -11,11 +11,14 @@ if __name__ == "__main__":
import sys import sys
app = QtWidgets.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)
translationFiles = glob.glob("i18n/*.qm")
translator = QtCore.QTranslator() translator = QtCore.QTranslator()
for translationFile in translationFiles: # get system locale
translator.load(translationFile) systemLocale = QtCore.QLocale.system().name()
app.installTranslator(translator) translationFile = "i18n/{}".format(systemLocale)
# load translation file and install translator
translator.load(translationFile)
app.installTranslator(translator)
# fire up main ui
ui = MainWindow() ui = MainWindow()
ui.show() ui.show()
sys.exit(app.exec_()) sys.exit(app.exec_())

View file

@ -5,6 +5,7 @@ from matplotlib.backends.backend_qt5agg import (FigureCanvasQTAgg as
from matplotlib.backends.backend_qt5agg import (NavigationToolbar2QT as from matplotlib.backends.backend_qt5agg import (NavigationToolbar2QT as
NavigationToolbar) NavigationToolbar)
from matplotlib.figure import Figure from matplotlib.figure import Figure
_translate = QCoreApplication.translate
class MplCanvas(FigureCanvas): class MplCanvas(FigureCanvas):
@ -30,13 +31,13 @@ class MplCanvas(FigureCanvas):
class CustomNavigationToolbar(NavigationToolbar): class CustomNavigationToolbar(NavigationToolbar):
toolitems = ( toolitems = (
(QCoreApplication.translate("CustomNavigationToolbar", 'Save'), (_translate("CustomNavigationToolbar", 'Save'),
QCoreApplication.translate("CustomNavigationToolbar", _translate("CustomNavigationToolbar",
'Save the figure'), 'filesave', 'Save the figure'), 'filesave',
'save_figure'), 'save_figure'),
(QCoreApplication.translate("CustomNavigationToolbar", 'Subplots'), (_translate("CustomNavigationToolbar", 'Subplots'),
QCoreApplication.translate("CustomNavigationToolbar", _translate("CustomNavigationToolbar",
'Configure subplots'), 'subplots', 'Configure subplots'), 'subplots',
'configure_subplots'), (None, None, None, None), ) 'configure_subplots'), (None, None, None, None), )
def __init__(self, canvas, parent, coordinates=True): def __init__(self, canvas, parent, coordinates=True):