/***************************************************************************
- * Copyright (C) 2005-09 by the Quassel Project *
+ * Copyright (C) 2005-2013 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "quassel.h"
#include "bufferinfo.h"
#include "types.h"
#include "syncableobject.h"
+#include "logger.h"
Quassel::BuildInfo Quassel::_buildInfo;
AbstractCliParser *Quassel::_cliParser = 0;
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
}