Manage translations
Requirements
Qt Linguist tools are used to manage translations. Typically on Ubuntu:
sudo apt install qttools5-dev-tools
Workflow
Generate the
plugin_translation.profile:python scripts/generate_translation_profile.pyUpdate
.tsfiles:pylupdate5 -noobsolete -verbose qchat/resources/i18n/plugin_translation.pro
Translate your text using QLinguist or directly into
.tsfiles. Launching it through command-line is possible:linguist qchat/resources/i18n/*.tsCompile it:
lrelease qchat/resources/i18n/*.ts
Notes
Remember that the resulting
*.qmfile should not be tracked in git history since it’s autogenerated and a binary file. The CI/CD pipeline will take care of generating it and packaging it. However, you can add the*.qmfile to.gitignoreto avoid any accidental commits.The
pylupdate5command is used to extract translatable strings from the source code and update the.tsfiles accordingly.The
-no-obsoleteflag is important to avoid removing obsolete translations, which can be useful for maintaining the history of translations and ensuring that no existing translations are lost during updates.The
-verboseflag is used to provide detailed output during the translation update process, which can be helpful for debugging and ensuring that the process is working correctly.The
linguistcommand is used to launch the Qt Linguist application, which provides a graphical interface for translating the.tsfiles. This can be more user-friendly than editing the files directly in a text editor.The
lreleasecommand is used to compile the.tsfiles into.qmfiles, which are binary files used by Qt applications for translations.