diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-06-06 12:10:34 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-06 12:10:34 -0700 |
commit | a0a6759d930c081d95d0984b4ffdbd1a55cf4961 (patch) | |
tree | fae7a20798e7c909d4e8e18e61e968b2c1fc7287 /qt-gui.cpp | |
parent | 98dd127f9350ac04b1895a1a126ff23579784537 (diff) | |
download | subsurface-a0a6759d930c081d95d0984b4ffdbd1a55cf4961.tar.gz |
User manual: show a localized version of the manual if it exists
So far we only have Spanish, but it always pays to plan ahead.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-gui.cpp')
-rw-r--r-- | qt-gui.cpp | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/qt-gui.cpp b/qt-gui.cpp index 3e898b979..224fdd597 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -76,9 +76,36 @@ void init_qt(int *argcp, char ***argvp) application = new QApplication(*argcp, *argvp); } +QString uiLanguage(QLocale *callerLoc) +{ + QSettings s; + s.beginGroup("Language"); + QLocale loc; + + if (!s.value("UseSystemLanguage", true).toBool()) { + loc = QLocale(s.value("UiLanguage", QLocale().uiLanguages().first()).toString()); + } + + QString uiLang = loc.uiLanguages().first(); + s.endGroup(); + + // there's a stupid Qt bug on MacOS where uiLanguages doesn't give us the country info + if (!uiLang.contains('-') && uiLang != loc.bcp47Name()) { + QLocale loc2(loc.bcp47Name()); + loc = loc2; + uiLang = loc2.uiLanguages().first(); + } + if (callerLoc) + *callerLoc = loc; + + return uiLang; +} + void init_ui(void) { QVariant v; + QSettings s; + // tell Qt to use system proxies // note: on Linux, "system" == "environment variables" QNetworkProxyFactory::setUseSystemConfiguration(true); @@ -102,24 +129,8 @@ void init_ui(void) QCoreApplication::setApplicationName("Subsurface"); // find plugins installed in the application directory (without this SVGs don't work on Windows) QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath()); - - QSettings s; - s.beginGroup("Language"); QLocale loc; - - if (!s.value("UseSystemLanguage", true).toBool()) { - loc = QLocale(s.value("UiLanguage", QLocale().uiLanguages().first()).toString()); - } - - QString uiLang = loc.uiLanguages().first(); - s.endGroup(); - - // there's a stupid Qt bug on MacOS where uiLanguages doesn't give us the country info - if (!uiLang.contains('-') && uiLang != loc.bcp47Name()) { - QLocale loc2(loc.bcp47Name()); - loc = loc2; - uiLang = loc2.uiLanguages().first(); - } + QString uiLang = uiLanguage(&loc); // we don't have translations for English - if we don't check for this // Qt will proceed to load the second language in preference order - not what we want |