Skip to content

Commit 738149c

Browse files
authored
Merge pull request #1455 from Factoid/command-line-parser
Command line parsing for easier language override
2 parents 9e779cf + 3617830 commit 738149c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/gui/qt/main.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,28 @@
2121

2222
#include "mainwindow.h"
2323
#include "sonicpilog.h"
24+
#include <iostream>
25+
2426
int main(int argc, char *argv[])
2527
{
2628
#ifndef Q_OS_MAC
2729
Q_INIT_RESOURCE(SonicPi);
2830
#endif
2931

3032
QApplication app(argc, argv);
31-
qRegisterMetaType<SonicPiLog::MultiMessage>("SonicPiLog::MultiMessage");
3233

34+
QCommandLineParser parser;
35+
parser.setApplicationDescription("Sonic-Pi");
36+
parser.addHelpOption();
37+
parser.addVersionOption();
38+
QCommandLineOption lang_opt = {{"l","lang"},QObject::tr("Override language to <locale>"),"locale"};
39+
parser.addOption(lang_opt);
40+
parser.process(app);
41+
42+
qRegisterMetaType<SonicPiLog::MultiMessage>("SonicPiLog::MultiMessage");
43+
3344
QString systemLocale = QLocale::system().name();
45+
if( parser.isSet(lang_opt) ) systemLocale = parser.value(lang_opt);
3446

3547
QTranslator qtTranslator;
3648
qtTranslator.load("qt_" + systemLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));

0 commit comments

Comments
 (0)