-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
46 lines (37 loc) · 1.22 KB
/
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
43
44
45
46
#include "MainWindow.h"
#include <QApplication>
#include <QTranslator>
#include <NotPrjRel.h>
#include <QLocale>
#include <QDebug>
#include <QDir>
QTranslator trQt, trApp;
void InstTranslator(QLocale locale);
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
IniSetting cfg("config.ini");
QString sLanguage = cfg.value("language", "System").toString();
if (sLanguage == "System")
InstTranslator(QLocale());
else if (sLanguage == "SimplifiedChinese")
InstTranslator(QLocale(QLocale::Chinese, QLocale::SimplifiedChineseScript, QLocale::China));
MainWindow w;
w.show();
return a.exec();
}
void InstTranslator(QLocale locale)
{
switch (locale.script()) {
// modified from qt office release
case QLocale::SimplifiedChineseScript:
qDebug()<< "ts qtMod"<< trQt.load(locale, "qtMod", "_", ":/translations");
break;
default:
qDebug()<< "ts qt"<< trQt.load(locale, "qt", "_", ":/translations");
break;
}
qDebug()<< "ts app"<< trApp.load(locale, "app", "_", ":/translations"); //fileName cannot be empty
qApp->installTranslator(&trQt);
qApp->installTranslator(&trApp);
}