diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mumble/main.cpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/mumble/main.cpp b/src/mumble/main.cpp index 947d419fe..42991c805 100644 --- a/src/mumble/main.cpp +++ b/src/mumble/main.cpp @@ -227,6 +227,7 @@ int main(int argc, char **argv) { QString rpcCommand; QUrl url; QStringList extraTranslationDirs; + QString localeOverwrite; if (a.arguments().count() > 1) { for (int i = 1; i < args.count(); ++i) { @@ -285,6 +286,12 @@ int main(int argc, char **argv) { " Print out the paths in which Mumble will search for\n" " translation files that overwrite the bundled ones.\n" " (Useful for translators testing their translations)\n" + " --locale <locale>\n" + " Overwrite the locale in Mumble's settings with a\n" + " locale that corresponds to the given locale string.\n" + " If the format is invalid, Mumble will error.\n" + " Otherwise the locale will be permanently saved to\n" + " Mumble's settings." "\n"); QString rpcHelpBanner = MainWindow::tr("Remote controlling Mumble:\n" "\n"); @@ -383,6 +390,14 @@ int main(int argc, char **argv) { qCritical("Missing argument for --translation-dir!"); return 1; } + } else if (args.at(i) == "--locale") { + if (i + 1 < args.count()) { + localeOverwrite = args.at(i + 1); + i++; + } else { + qCritical("Missing argument for --locale!"); + return 1; + } } else { if (!bRpcMode) { QUrl u = QUrl::fromEncoded(args.at(i).toUtf8()); @@ -548,9 +563,24 @@ int main(int argc, char **argv) { } #endif - QLocale settingsLocale = QLocale(Global::get().s.qsLanguage); - if (settingsLocale == QLocale::c()) { - settingsLocale = systemLocale; + QLocale settingsLocale; + + if (localeOverwrite.isEmpty()) { + settingsLocale = QLocale(Global::get().s.qsLanguage); + if (settingsLocale == QLocale::c()) { + settingsLocale = systemLocale; + } + } else { + // Manually specified locale overwrite + settingsLocale = QLocale(localeOverwrite); + + if (settingsLocale == QLocale::c()) { + qFatal("Invalid locale specification \"%s\"", qUtf8Printable(localeOverwrite)); + return 1; + } + + // The locale is valid -> save it to the settings + Global::get().s.qsLanguage = settingsLocale.nativeLanguageName(); } qWarning("Locale is \"%s\" (System: \"%s\")", qUtf8Printable(settingsLocale.name()), qUtf8Printable(systemLocale.name())); |