-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
42 lines (34 loc) · 963 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
#include <QStandardPaths>
#include <QDir>
#include <QFileInfo>
#include <QSettings>
#include <QTranslator>
#include "utils.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// set locale
QLocale locale(Utils::getLocalName());
QLocale::setDefault(locale);
qDebug() << Utils::getLocalName();
// set translator
QTranslator translator;
QStringList qmFiles = Utils::findQmFiles();
QString languageCode = locale.name().left(2);
qDebug() << qmFiles << languageCode;
foreach (const QString &qmFile, qmFiles) {
QFileInfo info(qmFile);
if (info.baseName() == QString("%1_%2").arg(a.applicationName(), languageCode)) {
qDebug() << qmFile;
translator.load(qmFile);
a.installTranslator(&translator);
break;
}
}
MainWindow w;
w.show();
return a.exec();
}