Created
January 23, 2015 06:51
-
-
Save stlehmann/3f4d226d7260a454fb65 to your computer and use it in GitHub Desktop.
add translator for Qt internals and application specific strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python3.4 | |
""" | |
Script for starting a PyQt5 Application. | |
""" | |
import sys | |
from PyQt5.QtWidgets import QApplication | |
from PyQt5.Qt import QLocale, QTranslator | |
from myapp import VERSION | |
app = QApplication(sys.argv) | |
app.setApplicationName("my app") | |
app.setOrganizationName("acme") | |
app.setApplicationVersion(VERSION) | |
# Translate Qt internals | |
locale = QLocale.system().name() | |
qtTranslator = QTranslator() | |
if qtTranslator.load("qtbase_" + locale, ":/transl"): | |
app.installTranslator(qtTranslator) | |
# Translate app texts | |
appTranslator = QTranslator() | |
if appTranslator.load("myapp_" + locale, ":/transl"): | |
app.installTranslator(appTranslator) | |
#start gui | |
dlg = MainWindow() | |
dlg.show() | |
app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment