Contributing Translations
We welcome community members to help improve Ghost Downloader's multilingual support! If you want to contribute new translations or update existing ones for the project, please follow these steps:
Environment Setup
You need to install the official Qt translation tools:
- PySide6: Ensure you have installed PySide6 and its related tools according to the steps in the Building from Source guide.
pyside6-lupdateandpyside6-lreleaseare usually installed along with PySide6. - Qt Linguist: This is a graphical translation editing tool used for editing
.tsfiles. You can download and install Qt from the official Qt website (select Tools -> Qt Linguist), or install it through your package manager (e.g.,sudo apt install qt6-tools-dev-toolson Debian/Ubuntu,brew install qt6on macOS).
Update Translation Source Files (.ts)
The project provides a script sync_i18n_res.py to automatically extract translatable text from the source code (.py files in the app/ directory) and update or create .ts files.
Run the script (Windows):
bash# Run in the project root directory python sync_i18n_res.pyThis will update the
gd3.zh_CN.tsandgd3.en_US.tsfiles in theresources/i18n/directory.Run the script (macOS/Linux): Currently, the
sync_i18n_res.pyscript does not automatically execute thepyside6-lupdatecommand on non-Windows platforms. You need to execute it manually:bash# Run in the project root directory # Assuming you want to update/create the en_US translation pyside6-lupdate app/**/*.py -ts resources/i18n/gd3.en_US.ts -source-language zh_CN -target-language en_US -no-ui-linesYou need to replace
app/**/*.pywith the actual list of files to scan (thesync_i18n_res.pyscript generates this list; you can refer to its logic or specify manually), and replaceen_USwith the target language code you want to process.Add a New Language: If you want to add a completely new language (e.g.,
fr_FRfor French), you need to:- Modify the
sync_i18n_res.pyscript, adding the new language code to thetargetLanguageslist. - Run the script (or manually execute
pyside6-lupdate) to generate the new.tsfile (e.g.,resources/i18n/gd3.fr_FR.ts). - Add support for the new language in
app/common/config.py(may require modifying enums or lists). - Ensure the new language's
.qmfile can be loaded correctly inGhost-Downloader-3.py.
- Modify the
Edit Translation Files (.ts)
Use the Qt Linguist tool to open the .ts file you need to edit (located in the resources/i18n/ directory).
- Translate the text from the source code item by item.
- For already translated items, ensure accuracy and update as needed.
- Save the
.tsfile when finished.
Generate Binary Translation Files (.qm)
After editing and saving the .ts file, you need to compile it into a binary .qm file that the application can load using the pyside6-lrelease tool.
# Run in the project root directory
# Compile all .ts files
pyside6-lrelease resources/i18n/gd3.*.ts
# Or compile a single file
# pyside6-lrelease resources/i18n/gd3.en_US.ts -qm resources/i18n/gd3.en_US.qmThe compiled .qm file will be placed in the same directory as the .ts file.
Submit Contribution
- Add your modified or new
.tsfiles and the generated.qmfiles to the Git staging area. - Commit your changes.
- Create a Pull Request to the main Ghost Downloader repository.
Thank you for contributing to the internationalization of Ghost Downloader!
