X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fquassel.cpp;h=c60f5ec1381036cbbe0d40d88b4ca645c0140124;hb=89ae7093aaf405d24f3d7ac0825290f2a065da99;hp=e9763fc7fec0dcc5c6451ee338069f9681bbe60b;hpb=4a5065255e652dd0c301bac0db41b7afb777ef49;p=quassel.git diff --git a/src/common/quassel.cpp b/src/common/quassel.cpp index e9763fc7..c60f5ec1 100644 --- a/src/common/quassel.cpp +++ b/src/common/quassel.cpp @@ -40,6 +40,7 @@ #include "bufferinfo.h" #include "types.h" #include "syncableobject.h" +#include "logger.h" Quassel::BuildInfo Quassel::_buildInfo; AbstractCliParser *Quassel::_cliParser = 0; @@ -494,10 +495,32 @@ void Quassel::loadTranslation(const QLocale &locale) quasselTranslator->setObjectName("QuasselTr"); qApp->installTranslator(quasselTranslator); - QLocale::setDefault(locale); +#if QT_VERSION >= 0x040800 + bool success = qtTranslator->load(locale, QString("qt_%1"), translationDirPath()); + if (!success) + qtTranslator->load(locale, QString("qt_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + quasselTranslator->load(locale, QString(""), translationDirPath()); +#else + QString localeName = locale.name(); + + // if the user did not specify a language in the settings, the system locale + // is used, but Qt < 4.8 does not respect language settings. This bit is + // based on QLocale::uiLanguages() as in Qt 4.8.3 + if (locale == QLocale::system()) { + // FIXME: does it make sense to set the locale to the system locale? + QLocale::setDefault(locale); + QVariant res = QSystemLocale().query(QSystemLocale::UILanguages, QVariant()); + if (!res.isNull()) { + QString newName = res.toStringList()[0]; + if (!newName.isEmpty()) { + localeName = newName.replace('-', "_"); // silly Qt. + } + } + } - bool success = qtTranslator->load(QString("qt_%1").arg(locale.name()), translationDirPath()); + bool success = qtTranslator->load(QString("qt_%1").arg(localeName), translationDirPath()); if (!success) - qtTranslator->load(QString("qt_%1").arg(locale.name()), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - quasselTranslator->load(QString("%1").arg(locale.name()), translationDirPath()); + qtTranslator->load(QString("qt_%1").arg(localeName), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + quasselTranslator->load(QString("%1").arg(localeName), translationDirPath()); +#endif }