Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please combine all the translations for each locale's modules into a single qt_??.qm file #194

Open
SlySven opened this issue Apr 11, 2025 · 2 comments

Comments

@SlySven
Copy link

SlySven commented Apr 11, 2025

https://doc.qt.io/qt-6/localization.html#deploy-translations mentions the following:

In addition to the application's QM files, you need to deploy the QM files for the Qt modules that you use in the application, unless they are installed on the system.

The QM files are split up by module and there is a so-called meta catalog file which includes the QM files of all modules. However, you only need to deploy the QM files for the modules that you use in the application.

You can use the lconvert tool in the deploy step to concatenate the required QM files into one file that matches the meta catalog file. For example, to create a German translation file for an application that uses the Qt Core, Qt GUI, and Qt Quick modules, run:

lconvert -o installation_folder/qt_de.qm qtbase_de.qm qtdeclarative_de.qm

I'm in the process of migrating my project from linuxdeployqt to linuxdeploy with the linuxdeploy-plugin-qt plugin and have just spotted that the latter is including (in my particular case) qtbase_xx.qm and qtmultimedia_xx.qm for each locale whereas the former does produce the combined qt_xx.qm that the above suggests. I would point you to the shared.cpp file in that project but since it is GPL licenced whereas this one is MIT I don't want to lead anyone to precisely copy what is there as it can't be used here. I'm guessing that (inline bool) deployTranslations(appdir::AppDir&, const fs::path&, const std::vector<QtModule>&) is the place to fix this...

@TheAssassin
Copy link
Member

Why would linuxdeploy have to do this, though? Wouldn't it be just as easy to run it manually if needed? I don't see the advantage (yet).

@SlySven
Copy link
Author

SlySven commented Apr 11, 2025

If they are not merged together then in an application it has to find and load the Qt translations for each module individually - whereas if they are combined it only has to instantiate one QTranslator instance to hold all the Qt modules' translations. In my application I'd have to rewrite https://github.com/Mudlet/Mudlet/blob/development/src/mudlet.cpp#L1376 to find each module's corresponding locale translation and then load them all making for more complexity.

I've worked around things temporarily by running linuxdeploy twice - the first time with this plug in - to assembly all the translation files, then used a bit of bashery to combine them in the manner that Qt themselves suggest (with lconvert) and then delete the individual files leaving behind the combined ones before running linuxdeploy again (without this plugin) to merge the changes back into the AppDir. Running linuxdeploy is not a particularly fast process - even in the GitHub CI/CB process (it takes a couple of minutes on my Desktop) so having to run it twice is not nice...

Ah, some timing details from the most recent run I've done like this: https://github.com/Mudlet/Mudlet/actions/runs/14411660189/job/40420749088?pr=7806

The first run with this qt and the gstreamer plugins:
Fri, 11 Apr 2025 20:53:25 GMT to Fri, 11 Apr 2025 20:54:19 GMT = 55 seconds
The second run without either plugin just to update the translation files in the AppImage after combining them:
Fri, 11 Apr 2025 20:54:19 GMT to Fri, 11 Apr 2025 20:54:56 GMT = 35 seconds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants