PDA

View Full Version : Qt dialogs in other lenguages...



Sparhawk
12th June 2008, 16:04
Hi,

I use QPrintDialog, QFileDialog, or QInputDialog in my Qt application, but when I use it I see it in english. Is it possible to translate to anothe language like spanish? I'm reading the Qt documentation but I'm not sure how to do it or if it is possible.

Thanks a lot

YuriyRusinov
12th June 2008, 16:37
Hello !

You have to write all titles, texts etc. using tr() function and put file with translations in your project.

Lesiok
13th June 2008, 09:39
Read about QTranslator.
You must create new QTranslator and set it in QApplication object. This is example code from my application which is working with Polish language.

QApplication app(argc, argv);
QTranslator qTtranslator;
qTtranslator.load("qt_pl",":/Resources");
app.installTranslator(&qTtranslator);

In QT dir look for qt_??.qm files.

roxton
13th June 2008, 11:18
Put this code to the constuctor of the main window:


QTranslator *qtTranslator = new QTranslator;
qtTranslator->load(QString("qt_%1").arg(QLocale::system().name()),
QLibraryInfo::location(QLibraryInfo::TranslationsP ath));
qApp->installTranslator(qtTranslator);


And read the documentation about the "Internationalization" item.