I want to convert the langauge of pyqt application from english to finnish . I saw that pyqt has some methods for it and i try to use it but it didnt help me
app = QtGui.QApplication(sys.argv)
translator = QtCore.QTranslator()
name = "File"
It seems you are mixing two things: the translations of Qt itself (which are provided via qt_xx.qm files and distributed along with Qt) and your own translations.
Here you have an example using the russian translation file of Qt itself:
from PyQt4.QtGui import * from PyQt4.QtCore import * class MyWindow(QWidget): def __init__(self, parent=None): super(QWidget, self).__init__(parent) self.hbox = QHBoxLayout(self) self.myButtons = QDialogButtonBox(self) self.hbox.addWidget(self.myButtons) button = self.myButtons.addButton(QDialogButtonBox.Open) if __name__ == "__main__": import sys app = QApplication(sys.argv) translator = QTranslator() print translator.load("qt_ru", QLibraryInfo.location(QLibraryInfo.TranslationsPath)) app.installTranslator(translator) ui = MyWindow() ui.show() sys.exit(app.exec_())
If you need your own translations then the Produce translations section of the i18n with Qt can be of help to you. You will need to provide a project file, your translation files (.ts) and use the Qt Linguist tool.
You can mix both the Qt itself translation and your own app translation by installing multiple translators.
Please note that when loading the translator you don't have to add the .qm extension to the filename.