summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-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();