summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-10-15 19:29:55 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-10-15 19:47:20 (GMT)
commit58d405a78bf82b9af63a48175ff0039f8cdd290c (patch)
tree6d5b2886b2678e65f231eebb17add74b563a4ebf /Swift/QtUI/main.cpp
parentb91731694dae519acae98a9f78f3655a4c71f03f (diff)
downloadswift-contrib-58d405a78bf82b9af63a48175ff0039f8cdd290c.zip
swift-contrib-58d405a78bf82b9af63a48175ff0039f8cdd290c.tar.bz2
Add command-line argument to override language.
Change-Id: Ie86689df58ed5134b1ed558d509d33123eb2bcbc
Diffstat (limited to 'Swift/QtUI/main.cpp')
-rw-r--r--Swift/QtUI/main.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/Swift/QtUI/main.cpp b/Swift/QtUI/main.cpp
index 9c99394..d02cce6 100644
--- a/Swift/QtUI/main.cpp
+++ b/Swift/QtUI/main.cpp
@@ -20,6 +20,7 @@
#include <Swift/Controllers/BuildVersion.h>
#include <SwifTools/Application/PlatformApplicationPathProvider.h>
#include <SwifTools/CrashReporter.h>
+#include <stdlib.h>
#include "QtSwift.h"
#include "QtTranslator.h"
@@ -34,23 +35,6 @@ int main(int argc, char* argv[]) {
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
- // Translation
- QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
- boost::filesystem::path someTranslationPath = applicationPathProvider.getResourcePath("/translations/swift_en.qm");
-
- QTranslator qtTranslator;
- if (!someTranslationPath.empty()) {
-#if QT_VERSION >= 0x040800
- qtTranslator.load(QLocale::system(), QString(SWIFT_APPLICATION_NAME).toLower(), "_", someTranslationPath.parent_path().string().c_str());
-#else
- //std::cout << "Loading " << std::string(QLocale::system().name().toUtf8()) << std::endl;
- qtTranslator.load(QString(SWIFT_APPLICATION_NAME).toLower() + "_" + QLocale::system().name(), someTranslationPath.parent_path().string().c_str());
-#endif
- }
- app.installTranslator(&qtTranslator);
- QtTranslator swiftTranslator;
- Swift::Translator::setInstance(&swiftTranslator);
-
// Parse program options
boost::program_options::options_description desc = Swift::QtSwift::getOptionsDescription();
boost::program_options::variables_map vm;
@@ -77,6 +61,29 @@ int main(int argc, char* argv[]) {
return 0;
}
+ // Translation
+ QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
+ boost::filesystem::path someTranslationPath = applicationPathProvider.getResourcePath("/translations/swift_en.qm");
+
+ QTranslator qtTranslator;
+ if (!someTranslationPath.empty()) {
+#if QT_VERSION >= 0x040800
+ if (vm.count("language") > 0) {
+ qtTranslator.load(QString(SWIFT_APPLICATION_NAME).toLower() + "_" + P2QSTRING(vm["language"].as<std::string>()), someTranslationPath.parent_path().string().c_str());
+ }
+ else {
+ qtTranslator.load(QLocale::system(), QString(SWIFT_APPLICATION_NAME).toLower(), "_", someTranslationPath.parent_path().string().c_str());
+ }
+#else
+ //std::cout << "Loading " << std::string(QLocale::system().name().toUtf8()) << std::endl;
+ qtTranslator.load(QString(SWIFT_APPLICATION_NAME).toLower() + "_" + QLocale::system().name(), someTranslationPath.parent_path().string().c_str());
+#endif
+ }
+ app.installTranslator(&qtTranslator);
+ QtTranslator swiftTranslator;
+ Swift::Translator::setInstance(&swiftTranslator);
+
+
Swift::QtSwift swift(vm);
int result = app.exec();