How to make multilingual QT UI application?

316 Views Asked by At

I am working on a new project where I am required to develop a simple desktop based Qt application for a car parking company. This application should be actually residing on the Linux machines sitting at the Entry & Exit of the car park.

Now my real problem is to make this application Multilingual. Right now i am using Qt 4.8.6 & have gone through certain documentation on the below links

http://doc.qt.io/qt-4.8/linguist-manual.html

http://doc.qt.io/qt-4.8/linguist-translators.html

Since my application UI is very simple with no complex phrases or huge data to be transalated, I am looking for any other alternative than what is suggested in the above two links.

I request the experts to suggest the best alternative that I can go with.

Also please let me know if this is a good idea "Having a Qt Web Application which can interact with the c++ logic. In this way I can have run time easy translation of web pages (as easy as using Google translator on web page) & having it on the Qt window"

Please Suggest the best way to acheive this.

1

There are 1 best solutions below

0
On BEST ANSWER

I would recommend to use the QTranslator like:

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

    QTranslator qtTranslator;
    qtTranslator.load("qt_" + QLocale::system().name(),
            QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    app.installTranslator(&qtTranslator);

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

    // You app runs here

    return app.exec();
}

The translation will be stored in ts-files, which can be generated via the lupdate / lrelease workflow including all tools provided by the Qt-framework.