{%hackmd theme-dark %} Мультиязычность в приложениях Qt = ###### tags: `Qt` 1. Генерация файлов ts из py и ui для перевода ``` C:\Python34\Lib\site-packages\PyQt5\pylupdate5 main.py MainWindow.py MainWindow.ui -ts Watcher_ru.ts ``` 1. Создание перевода в Linguist.exe 1. Преобразование ts в qm в Linguist или утилитой lrelease : ``` C:\Python34\Lib\site-packages\PyQt5\lrelease Watcher_ru.ts ``` 1. Использование в основном коде: ```python= import sys from PyQt5.QtCore import QTranslator from PyQt5.QtWidgets import QApplication from MainWindow import MainWindow if __name__ == '__main__': app = QApplication(sys.argv) translator = QTranslator() translator.load("Watcher_ru") # Watcher_ru.qm if not app.installTranslator(translator): print("Can not install translation!") w = MainWindow() w.ui.retranslateUi(w) app.exec() ```