from PySide2.QtWidgets import QApplication from PySide2.QtCore import QTranslator import sys app = QApplication(sys.argv) translator = QTranslator() translator.load("C:/path/to/translation/file.qm") app.installTranslator(translator) # Your application code here sys.exit(app.exec_())
from PySide2.QtWidgets import QApplication from PySide2.QtCore import QTranslator import sys app = QApplication(sys.argv) translator = QTranslator() translator.load(":/path/to/translation/file.qm") app.installTranslator(translator) # Your application code here sys.exit(app.exec_())This example shows how to install a translation file that is embedded in a resource file. You load the translation file using its resource path, which starts with a colon followed by the path to the file inside the resource file. If you don't know what a resource file is, it's a file that contains other files that your application needs. Package library: PySide2.