summaryrefslogtreecommitdiffstats
path: root/Swift
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
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')
-rw-r--r--Swift/QtUI/QtSwift.cpp3
-rw-r--r--Swift/QtUI/main.cpp41
2 files changed, 27 insertions, 17 deletions
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index 13b2175..223f3ae 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -82,6 +82,9 @@ po::options_description QtSwift::getOptionsDescription() {
("latency-debug", "Use latency debugging (unsupported)")
("multi-account", po::value<int>()->default_value(1), "Number of accounts to open windows for (unsupported)")
("start-minimized", "Don't show the login/roster window at startup")
+#if QT_VERSION >= 0x040800
+ ("language", po::value<std::string>(), "Use a specific language, instead of the system-wide one")
+#endif
;
return result;
}
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();