Fix a bug

#20
I got a wrong tutorial saying that I should use xxx.ts on Linux
pull/33/head
wh201906 3 years ago
parent bac6207634
commit 3523c1eace

@ -5,11 +5,13 @@
#include <QTranslator> #include <QTranslator>
#include <QMessageBox> #include <QMessageBox>
#include <QTextCodec> #include <QTextCodec>
#include <QDir>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
QDir *langPath = new QDir();
QApplication a(argc, argv); QApplication a(argc, argv);
MainWindow w; MainWindow w;
@ -29,14 +31,10 @@ int main(int argc, char *argv[])
else else
currLang = "en_US"; currLang = "en_US";
} }
currLang = "lang/" + currLang;
#ifdef Q_OS_WIN
currLang += ".qm"; currLang += ".qm";
#else langPath->cd("lang");
currLang += ".ts";;
#endif
QTranslator* translator = new QTranslator(&w); QTranslator* translator = new QTranslator(&w);
if(translator->load(currLang)) if(translator->load(currLang, langPath->absolutePath()))
{ {
a.installTranslator(translator); a.installTranslator(translator);
} }
@ -45,6 +43,7 @@ int main(int argc, char *argv[])
QMessageBox::information(&w, "Error", "Can't load " + currLang + " as translation file."); QMessageBox::information(&w, "Error", "Can't load " + currLang + " as translation file.");
} }
delete settings; delete settings;
delete langPath;
w.initUI(); w.initUI();
w.show(); w.show();
return a.exec(); return a.exec();

Loading…
Cancel
Save