[PyQt] Fwd: translation of ui

Thorsten Kampe thorsten at thorstenkampe.de
Sat Jul 2 14:50:33 BST 2011


* Yasar Arabaci (Fri, 1 Jul 2011 12:52:09 +0300)
> I got it working but wanted to get an affimation, what do you think of
> this approach?
> 
> if __name__ == "__main__":
>     from locale import getlocale
>     from os.path import exists
>     app = QtGui.QApplication(sys.argv)
>     if getlocale()[0]:
>         if exists("translations/" + getlocale()[0] + ".qm"):
>             translator = QtCore.QTranslator(app)
>             translator.load(getlocale()[0] + ".qm", "translations")
>             app.installTranslator(translator)
>     window = MainWindow()
>     window.show()
>     sys.exit(app.exec_())

This is all I have in my (template-like) application:

app = QtGui.QApplication(sys.argv)
# Internationalization
appTranslator = QtCore.QTranslator()
appTranslator.load(':/app.qm')
app.installTranslator(appTranslator)
#
mainWin = MainWindow()
mainWin.show()
app.exec_()

Thorsten



More information about the PyQt mailing list