When building a project in Qt Creator, these lines in the .pro file:
CONFIG += lrelease
CONFIG += embed_translations
QM_FILES_RESOURCE_PREFIX=/lang
will get the .qm translation files embedded in the built executable. The application can then load translations like this:
translator.load(":/lang/file_name.qm")
I am trying to replicate this behaviour when building the project in Visual Studio with the Qt VS Tools extension, to no avail.
I have tried fiddling with the settings available inside the project configuration properties (Qt Project Settings / qmake / Additional project settings) to no avail.
When the project includes any .ts file, Visual Studio adds a "Qt Translation" page to the project properties. Here, the "Run translation tool during build" entry gets the .qm files generated at build time, which takes care of
CONFIG += lrelease
It is also possible to specify the output directory for the .qm files. However, I have found no way to replicate these two:
QM_FILES_RESOURCE_PREFIX=/lang
CONFIG += embed_translations
to get the .qm files embedded as executable resources, available under the ":/lang/" prefix
I am using VS2019 with the latest Qt VS Tools extension. I guess it is not any different with VS2022, since they share the same Qt extension code base.