D
D
DonLeoN2016-01-29 17:25:29
PyQt
DonLeoN, 2016-01-29 17:25:29

How to translate a program into Python?

Good day everyone!
Wrote a small text editor and ran into this problem. Buttons in pop-up windows in English (QMessageBox.Yes, for example). I found on the Internet how to translate all the keys in the program, but there is no result.
I'm using PyQt5. If anyone knows the solution, write in detail how to write it correctly or what exactly I wrote wrong.

if __name__=='__main__':
    app = QApplication(sys.argv)
    locale = QLocale.system().name()
    QTranslator = QTranslator()
    if QTranslator.load('C:/Python34/Lib/site-packages/PyQt5/translations/qt_' + locale):
        app.installTranslator(QTranslator)
    window = Edit()
    window.show()
    sys.exit(app.exec_())

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abs0lut, 2016-01-29
@abs0lut

If the standard buttons are not flexible enough for your message box, you can use the addButton() overload that takes a text and a ButtonRole to add custom buttons. The ButtonRole is used by QMessageBox to determine the ordering of the buttons on screen (which varies according to the platform).

pyqt.sourceforge.net/Docs/PyQt4/qmessagebox.html#a...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question