#include <QHostInfo>
#include <QIcon>
#include <QInputDialog>
+#include <QLibraryInfo>
#include <QLocale>
#include <QMenu>
#include <QMessageBox>
}
}
+static inline void loadTranslation(QTranslator&trans,const QString&lang,const QString&prog)
+{
+ QStringList lpath;
+ lpath <<QApplication::applicationDirPath() <<QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ for(int i=0;i<lpath.size();i++){
+ bool ok=trans.load(prog+"_"+lang,lpath[i]);
+ QString msg=QString("...loading %1_%2 from %3 ...%4")
+ .arg(prog).arg(lang)
+ .arg(lpath[i])
+ .arg(ok?"ok":"failed");
+ qDebug("%s",msg.toAscii().data());
+ if(ok)return;
+ }
+}
+
int main(int argc,char**argv)
{
//create global app
QLocale::setDefault(QLocale(lang));
qDebug("Loading language %s",lang.toAscii().data());
QTranslator qttrans;
- bool ok=qttrans.load("qt_"+lang,QApplication::applicationDirPath());
- qDebug("...loading qt_%s ...%s",lang.toAscii().data(),ok?"ok":"failed");
+ loadTranslation(qttrans,lang,"qt");
app.installTranslator(&qttrans);
QTranslator mstrans;
- ok=mstrans.load("smoke_"+lang,QApplication::applicationDirPath());
- qDebug("...loading smoke_%s ...%s",lang.toAscii().data(),ok?"ok":"failed");
+ loadTranslation(mstrans,lang,"smoke");
app.installTranslator(&mstrans);
if(lang!="--"&&lang!="")
QLocale::setDefault(lang);