Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QT - Read translator file .ts/.qm on translations.qrc file
lele86 last edited by
Hi guys, I'm trying to import translator file on my qt project (QT 5.6 on linux system), but I can't upload translation file because "load" function of "QTranslator" returns always "false".
I have the following project structure:
Project root: /
/resources/translations/app_it .qm and .ts
/resources/translations/app_en .qm and .ts
In main.cpp file of qt application I have the following source code:
QTranslator *translator = new QTranslator(); bool isFileTranslatorLoaded = translator->load(":/translations/translations/app_it);
isFileTranslatorLoaded always returns false.
<RCC> <qresource prefix="/translations"> <file>translations/app_it.ts</file> <file>translations/app_it.qm</file> <file>translations/app_en.ts</file> <file>translations/app_en.qm</file> <qresource> <RCC>
How can I solve this issue?
Thanks in Advice
Best Regards Daniele
Hi and welcome to devnet,
You are passing an invalid path. You only need the processed version
.qmthere's no need for the
lele86 last edited by lele86
I have followed your suggestions but isFileTranslatorLoaded returns always false. In c++ code I wrote bool "isFileTranslatorLoaded = translator->load(":/translations/appit.qm");" and my resource file is:
<qresource prefix="/translations" lang="it">
<qresource prefix="/translations" lang="en">
I don't know why the .qm file isn't loaded. It seems that the resource file is not loaded in the main.cpp file.
Thanks in advice.
Because you are using
lang="it"this means that the file is only available if your locale is Italian. See the resources chapter in Qt's documentation for a more thorough explanation.
ahmad88me last edited by
Hi @SGaist , This doesn't work for me as well. I tried with using
lang=arand without the
What exactly doesn't work ?