PDA

View Full Version : QFileDialog/ QMessageBox's Button Translation problem



santosh.kumar
7th August 2009, 07:08
Hi

We are using Unicode i.e. French Version for our product.
Everything is translated at runtime like Dialog, messagecontent and other string
using Qt linguist, QTranslator
and using qApp->installTranslator(&trans);


But problem is that I m using QMessageBox & QFileDialog .
QMessageBox's content translated into french at runtime but its Button's content remains is English like Ok, Cancel

Samething I m using QFileDialog to open file..

QString str = QFileDialog(/* argument */);

Whenver this Qt' dialog open, Its three Button New Folder, Open, Cancel will not translated automatically it show in English.

Same thing for QFileDialog::getExistingDirectory(/* */);

Its button Save , Cancel is not translated into French it show in English .



Is there anything that we r missing.
If anybody know this issue , kindly give me solution.

Thanks & regards
Santosh Kumar Singh

yogeshgokul
7th August 2009, 07:12
Use this option:

QFileDialog::DontUseNativeDialog

santosh.kumar
7th August 2009, 08:01
I want to use this in MacOS

I want to open as a sheet and all Volumes should thatswhy we have used QFileDialog::ShowDirOnly instead of QFileDialog::DontUseNativeDialog .

But This show all Button in English like Ok, Save, Cancel, New Folder etc..

This is Qt's inbuild FileDialog and How we can translate its Button text in French at runtime..


Thanks

yogeshgokul
7th August 2009, 08:23
This is Qt's inbuild FileDialog and How we can translate its Button text in French at runtime

You can set, because like all other Qt classes, QFileDialog is also implemented in such a way, so you can use it with different languages. You can not change the language of OS specific native dialog. Thats why I suggested to use option DontUseNativeDialog.
Every text in QFileDialog is entered using tr() (http://doc.trolltech.com/4.5/qtranslator.html), so use can do translation.

santosh.kumar
7th August 2009, 09:35
We have used this QFileDialog::DontUseNativeDialog but it will not best suit for out application..because its not look like MacOS's dialog...

We have to use QFileDialog's getSavefileName, getExistingdirectory, getOpenFileName
...Kindly tell me another solution for this so that we can show translated button text at run time in French..

QFileDialog::getSavefileName( );
It contains three button - New Folder, Cancel , Save.

Whenever my app run in French MACOSX all string translated but this button text is not translated....Plz tell me another solution...

segi
8th August 2009, 10:17
You have to add Qt's own translation files to your app. (look at http://doc.qtsoftware.com/i18n.html#produce-translations)
You find the qm-files in $QTDIR/translations.


int main(int argc, char *argv[])
{
QApplication app(argc, argv);

// qt translation for default dialogs (QFileDialog) and so on
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsP ath));
app.installTranslator(&qtTranslator);

// your own translation
QTranslator myappTranslator;
myappTranslator.load("myapp_" + QLocale::system().name());
app.installTranslator(&myappTranslator);

...
return app.exec();
}

santosh.kumar
10th August 2009, 07:07
Ok nice ...
We found the Translations path for Default dialog..
We found qt_fr.qm for franchese translation....

We are using these code

qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsP ath));
It is loading qt_fr.qm file.

We r using Qt 4.3.4 for Mac OS.
But whenever we make Exe of our application I think we have to include This Qt's Translation folder in our App's -> Contents->Resources->Translation->qt_fr.qm.

Or any other solution to include this translation path in our Application's Exe.