[PyQt] Fwd: translation of ui

Sebastian Wiesner lunaryorn at googlemail.com
Sat Jul 2 11:23:05 BST 2011


2011/7/1 Yaşar Arabacı <yasar11732 at gmail.com>:
> 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_())

I'd use "QLocale.system().name()" instead of "locale.getlocale()", as
recommended in the Qt documentation.  The rest looks ok.


More information about the PyQt mailing list