PDA

View Full Version : Not all Widgets are Translated



Halcom
2nd December 2010, 08:08
Hi,

my problem is that not all widgets are translated. Nearly 95% work. I checked several things, but now i dont know there the problem could be. Her are the important things.


Qt 4.7.0, Qt Creator 2.0.1, Qt Linguist 4.7.0
QTranslator is member of my GUIApplication class derived from QApplication and loaded before app.exec() is called. (95% Works :) )
No retranslation will be done, translation file is only loaded once at startup
Text is in tr() macro
Translation (.ts) file have correct translation entry and is finished.
qm File was recreated but does not solve the problem, loading of right file was checked
Problem also contains some .ui translations


Any proposals?
Thx

wysota
2nd December 2010, 08:50
Any proposals?
Hard to suggest anything without knowing any details. Try to find a pattern saying which texts are not translated.

Halcom
3rd December 2010, 14:31
I have not found any pattern. But if found that the Translation are only incorrect in RELEASE build. I have recompiled whole Project (with qmake), but that does not solve the Problem.

wysota
3rd December 2010, 14:59
That's a pattern too. Check if you don't have an incomplete duplicate of the translation file in your release folder or somewhere else where Qt might have picked up the translation from.

Halcom
3rd December 2010, 15:15
Thats allready checked, both build take it from <applicationFolder>/data/german.qm and the build is for debug and release in same folder.

Destination dir is set in .pro file with:

DESTDIR = Bin

wysota
3rd December 2010, 20:23
Thats allready checked, both build take it from <applicationFolder>/data/german.qm
How do you check that?

Halcom
6th December 2010, 07:09
Creating a debug output with qDebug() with path of file that is loaded. In Debug and Release version this is the same path.

wysota
6th December 2010, 07:43
Can we see the code?

Halcom
6th December 2010, 08:52
Ok, sorry. It was not qDebug. But the Path are the same.

Release: F:/MKan/Projekte/ImageCapture-build-desktop/Bin/Data/deutsch.qm
Debug: F:/MKan/Projekte/ImageCapture-build-desktop/Bin/Data/deutsch.qm

Here the inportant code parts.




GUIApplication(...)
: QApplication(...)
, ...
{
...
// setup common application data path
#ifdef Q_WS_WIN
QSettings registryCommon("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\ CurrentVersion\\Explorer\\Shell Folders", QSettings::NativeFormat);
mCommonApplicationDataFolder = registryCommon.value("Common AppData").toString();
mCommonApplicationDataFolder = mCommonApplicationDataFolder.replace("\\", "/");
#else
mCommonApplicationDataFolder = QDir::homePath() + "/.config/";
#endif

if(!mCommonApplicationDataFolder.endsWith("/"))
mCommonApplicationDataFolder.append("/");

if(mVendor.isEmpty())
mCommonApplicationDataFolder.append(applicationNam e() + "/");
else
mCommonApplicationDataFolder.append(mVendor + "/" + applicationName() + "/");

mCommonSettings = new GUISettings(mCommonApplicationDataFolder + "Settings.ini", this);

// set translation file, mTransalator is Member
const QString languageFilePath = applicationDirPath() + "/data/" + language();

showMessage(eInformation, languageFilePath + ".qm");

const QFile languageFile(languageFilePath + ".qm");
if( languageFile.exists())
if(mTranslator.load(languageFilePath))
installTranslator(&mTranslator);
...
}

void GUIApplication::exec()
{
...
mMainWindow = new GUIMainWindow();
if( !applicationName().isEmpty() )
mMainWindow->setWindowTitle(applicationName() + " " + applicationVersion());
mMainWindow->show();

for( int i = 0; i < mMessageList.count(); i++)
showMessage(mMessageList.at(i).type, mMessageList.at(i).message, mMessageList.at(i).later);

mMessageList.clear();

return QApplication::exec();
}

void GUIApplication::showMessage( MessageType iType, const QString & iMessage, bool iShowLater )
{
if( mMainWindow )
mMainWindow->showMessage( iType, iMessage, iShowLater );
else
{
MessageData data;
data.type = iType;
data.message = iMessage;
data.later = iShowLater;

mMessageList.append(data);
}
}

QString GUIApplication::language() const
{
return mCommonSettings->value("Language", "english").toString();
}