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:
parent
750a9b7157
commit
e1b0edd292
2 changed files with 14 additions and 10 deletions
11
main.py
11
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_())
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue