Solved removeTranslator fails?
-
Hi,
Might be a silly question but are you sure your translations are loaded successfully as well ?
-
@SGaist Yes, I implemented the following codes to verify:
successLoad = mTranslator.load("lang_de.qm", mLangDir); successInstall = qApp->installTranslator(&mTranslator); qInfo() << "Load trans file successful?" << successLoad; qInfo() << "Trans install successful?" << successInstall;
They always printed out true.
Basically, every time when a qm file is loaded initially, everything is fine. Butwhen I try to switch to another qm file,
removeTranslator
seems failed, and the corresponding texts don't display properly -
Is mTranslator modified at some point in your application ?
Where is it located ? -
@SGaist mTranslator is declared as the private member of this Class,
QTranslator mTranslator
I don't think it's being changed somewhere else. Thank you -
You call removeTranslator() twice so the second one will fail. Please check the return value of the first one.
-
@SGaist Thank you for your help, I resolved this problem myself. If you would like to check the update in my question
-
@Christian-Ehrlicher Thank you, I resolved this problem myself
-
Haaaaa ! I somehow missed that you were doing that in a QML app...
Glad you found out and thanks for sharing !
Since you have it working now please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :-)
-
However,
removeTranslator
still returns false, but this doesn't affect the translation, I am a bit confusedThat's because of what @Christian-Ehrlicher said:
You call removeTranslator() twice so the second one will fail. Please check the return value of the first one.
-
@QTLeearn said in removeTranslator fails?:
I resolved the problem my self,
Great. Please don't forget to mark your post as solved!