View Single Post
Posts: 435 | Thanked: 769 times | Joined on Apr 2010
#412
http://warmi.net/docs/qt_4.6.3/html/tools-i18n.html

This is a nice example of translations with doesn't require code changing to include new translations.

From my experience translated files are not seen if their names are different from appname.LANGUAGECODE.qm .

To automatically change language I code like this:
Code:
#include <QApplication>
#include "mainwindow.h"
#include <QtSystemInfo/QSystemInfo>
#include <QTranslator>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QtMobility::QSystemInfo *systemInfo;
    QTranslator translator;

    if (systemInfo->currentLanguage() == "it")
   {
        translator.load("appname.it", "/opt/appname");
        a.installTranslator(&translator);
    }

    MainWindow w;
    w.show();

    return a.exec();
}
appname.it.qm is the translated file.


QML version of cuteTube rules.
 

The Following User Says Thank You to gionni88 For This Useful Post: