How to use Qt translation resources?
-
Each Qt library contains translation resources (files *.qm) which is usually located in:
<QTFOLDER>/qtbase/translations/I want to include these files in my myapp_resources.qrc file, but I do not want to specify the full path, because in this case when I decide to change the Qt library, I should be changing these paths also.
Is it possible to include these files in my resources using special macros like a, for example:
<file>$QTFOLDER/qtbase/translations/qtbase_bg.qm</file>
If these macros exist, which should use?
If it's not possible then, how to use these resources?
-
Actually the usual way is just deploying the translation files with the executable file.
When you use windeployqt tool on Windows, some translation files will be copied just like the plugins by default.If you want to add them to the resource it is also possible.
I think you can't use MACROs in qrc file.
But you can use them in the .pro file and let it generate a qrc file for you.qm_file.files = $$[QT_INSTALL_TRANSLATIONS]/qtbase_bg.qm #can be multiple files qm_file.base = $$[QT_INSTALL_TRANSLATIONS] #add relative alias automatically qm_file.prefix = i18n RESOURCES += qm_file
This will generate a qrc file
qmake_qm_file.qrc
in the build folder and add it to the Makefile.
Then you would be able to access the file by:/i18n/qtbase_bg.qm
.