You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Qt:llä voi Linguist softalla tuottaa eri kieliversioita. Projektitiedostoon tehdään esimerkiksi seuraavat asetukset:


TRANSLATIONS = senderi_en.ts

CODECFORSRC = UTF-8
CODECFORTR = UTF-8

Pääohjelmaan laitetaan kielitiedostojen lataus.

#include <QApplication>
#include <QTranslator>
#include <QLocale>

#include "sender.h"

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    bool englishLanguageSelected=false;
    // if there is command line parameter that sets the language, show UI in that language
    QTranslator translator;
    QStringList params = QCoreApplication::arguments();
    QString currentparam;
    for (int i = 0; i < params.size(); ++i){
        currentparam=params.at(i).toLower();
        if( currentparam=="--lang=en"){
            translator.load(QString("senderi_") + "en");
            app.installTranslator(&translator);
            englishLanguageSelected=true;
        }
    }
    if(!englishLanguageSelected){
        QLocale::setDefault(QLocale(QLocale::Finnish,QLocale::Finland));
    }
    Sender sender;
    sender.show();
    return sender.exec();
}


  • No labels
You must log in to comment.