This is a basic example of implementing dynamic language switching when running an application in PySide and QML. It was only tested with PySide6, but I believe it can be adapted to PyQt5/6 and PySide2 without complications.
[English | Portuguese]
- Qt Linguist (see: qtlinguist-installers | thurask/Qt-Linguist) or other translation software (eg OmegaT)
- Code editor
Here are tips on how to get the texts and compile them
Extract translatable texts:
lupdate .\main.qml -ts .\locale\en-US.ts .\locale\fr-FR.ts .\locale\zh-CN.ts
In this example, the texts are extracted from the main.qml file and exported in .ts format in the locale folder according to the specified names.
At this point translate these files using the translation software.
Compiling translated texts: If you want to compile all languages at once
lrelease .\locale\*.ts
Or if you just want a specific one:
lrelease .\locale\fr-FR.ts