I'm creating a multilanguage desktop app using Qt Designer and PyQt5. I'm following this answer to make my app change languages dynamically.
I've created a .ui file via Qt Designer and I'm loading the UI directly in python code via loadUi. Therefore, the function retranslateUi is described in my ui.file unlike the retranslateUi function in link above (it is present in python code). I wouldn't like to put the described function in python code because there's a lot buttons and labels. How can I use this function in my code and to keep it only in .ui file?
uic.loadUi
If you use the loadUi method it doesn't implement the retranslateUi method so if you use that method then the solution is the same as the previous post.
demo.ui
main.py
Then generate the .ts:
Then use Qt Linguist to do the translations.
And finally the .qm:
pyuic
On the other hand, if you are using pyuic5 to convert the .py then if the retranslateUi method is implemented so you can use it:
Then use Qt Linguist to do the translations.
And finally the .qm:
main.py