Translations not working after deployment
-
I just deployed my application with windeployqt and the resulting .exe doesn't translate the ui unless I add the .qm file to the same directory as I do when I compile my app.
I thought that all the files in the resource file are compiled into the .exe but it is not happening with the .qm file as all the other files added in the resource seem to be working fine.
I have set up
bool
variables that check the result ofQTranslator::load
, when I compile the code it works as expected but after deployment it doesn't.I have no problem in adding the .qm file to the deployment directory but if I don't have to I would like not to because it's safer.
-
@hbatalha said in Translations not working after deployment:
I thought that all the files in the resource file are compiled into the .exe but it is not happening with the .qm file as all the other files added in the resource seem to be working fine.
They are. But your qm-file is in your binary dir whereas the rest is in your source dir so make sure the correct qm file is icked up. Also check with QFile::exists() if the qm file is available.
-
your qm-file is in your binary dir whereas the rest is in your source dir
What do you you mean? They are all in the same folder.
Also check with QFile::exists() if the qm file is available.
The load operation is successful, doesn't that mean the file exists?
-
@J-Hilk said in Check for QTranslator::load:
@hbatalha
what @nagesh meant is:translatorPt.load("transl_portuguese.qm", ":/Languages/"))
file path is now your qrc system and not currentPath
-
@hbatalha said in Translations not working after deployment:
The load operation is successful, doesn't that mean the file exists?
but after deployment it doesn't.
What now?
-
@hbatalha said in Translations not working after deployment:
I thought that all the files in the resource file are compiled into the .exe but it is not happening with the .qm file as all the other files added in the resource seem to be working fine.
Please show us your QTranslator::load() call. You most likely need to tweak it to actually load the .qm file's content from the resource system...
-
@hbatalha
check out this thread
https://forum.qt.io/topic/74995/load-qm-file-from-resource/15the op never responded after a couple of solution suggestions, I assume one of them works 🤷♂️
-
I have found out what was the problem. For some reason I don't know every time I build the application Qt Creator will create the binary in the debug folder even though I have it set to release.
None of the changes I was making was actually taking effect since I was always checking .exe file from the release which was remaining unchanged the whole time.
So I took the .exe from the debug folder and deployed it and all is working fine. Now I have to check what might me going when building my app cause the .exe is pretty big and I am not sure if is the release or the debug(it is in the debug folder, but I built it with release build set).
I thank you all for the time and patience. I really appreciated it.
-
Any chances you are on Windows ?
-
Using Visual Studio ?
-
I mean the compiler.