diff --git a/main.py b/main.py index 0ea71c9..3fe1704 100644 --- a/main.py +++ b/main.py @@ -11,11 +11,14 @@ if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) - translationFiles = glob.glob("i18n/*.qm") translator = QtCore.QTranslator() - for translationFile in translationFiles: - translator.load(translationFile) - app.installTranslator(translator) + # get system locale + systemLocale = QtCore.QLocale.system().name() + translationFile = "i18n/{}".format(systemLocale) + # load translation file and install translator + translator.load(translationFile) + app.installTranslator(translator) + # fire up main ui ui = MainWindow() ui.show() sys.exit(app.exec_()) diff --git a/ui/mplwidget.py b/ui/mplwidget.py index c4d989f..a4e4af1 100644 --- a/ui/mplwidget.py +++ b/ui/mplwidget.py @@ -5,6 +5,7 @@ from matplotlib.backends.backend_qt5agg import (FigureCanvasQTAgg as from matplotlib.backends.backend_qt5agg import (NavigationToolbar2QT as NavigationToolbar) from matplotlib.figure import Figure +_translate = QCoreApplication.translate class MplCanvas(FigureCanvas): @@ -30,13 +31,13 @@ class MplCanvas(FigureCanvas): class CustomNavigationToolbar(NavigationToolbar): toolitems = ( - (QCoreApplication.translate("CustomNavigationToolbar", 'Save'), - QCoreApplication.translate("CustomNavigationToolbar", - 'Save the figure'), 'filesave', + (_translate("CustomNavigationToolbar", 'Save'), + _translate("CustomNavigationToolbar", + 'Save the figure'), 'filesave', 'save_figure'), - (QCoreApplication.translate("CustomNavigationToolbar", 'Subplots'), - QCoreApplication.translate("CustomNavigationToolbar", - 'Configure subplots'), 'subplots', + (_translate("CustomNavigationToolbar", 'Subplots'), + _translate("CustomNavigationToolbar", + 'Configure subplots'), 'subplots', 'configure_subplots'), (None, None, None, None), ) def __init__(self, canvas, parent, coordinates=True):