From cef150eee61d0269838d9978cdbb751146336cc8 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sat, 26 Mar 2016 03:23:39 +0200 Subject: [PATCH] Fix selection of Esperanto locale. Closes #4999. --- src/gui/options_imp.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/gui/options_imp.cpp b/src/gui/options_imp.cpp index aef1b59e3..839f7fe87 100644 --- a/src/gui/options_imp.cpp +++ b/src/gui/options_imp.cpp @@ -316,14 +316,21 @@ options_imp::options_imp(QWidget *parent) void options_imp::initializeLanguageCombo() { // List language files - const QDir lang_dir(":/lang"); - const QStringList lang_files = lang_dir.entryList(QStringList() << "qbittorrent_*.qm", QDir::Files); - foreach (QString lang_file, lang_files) { - QString localeStr = lang_file.mid(12); // remove "qbittorrent_" + const QDir langDir(":/lang"); + const QStringList langFiles = langDir.entryList(QStringList("qbittorrent_*.qm"), QDir::Files); + foreach (const QString langFile, langFiles) { + QString localeStr = langFile.mid(12); // remove "qbittorrent_" localeStr.chop(3); // Remove ".qm" - QLocale locale(localeStr); - QString language_name = languageToLocalizedString(locale); - comboI18n->addItem(/*QIcon(":/icons/flags/"+country+".png"), */ language_name, localeStr); + QString languageName; + if (localeStr == "eo") { + // QLocale doesn't work with that locale. Esperanto isn't a "real" language. + languageName = QString::fromUtf8(C_LOCALE_ESPERANTO); + } + else { + QLocale locale(localeStr); + languageName = languageToLocalizedString(locale); + } + comboI18n->addItem(/*QIcon(":/icons/flags/"+country+".png"), */ languageName, localeStr); qDebug() << "Supported locale:" << localeStr; } } @@ -1217,8 +1224,14 @@ QString options_imp::getLocale() const void options_imp::setLocale(const QString &localeStr) { - QLocale locale(localeStr); - QString name = locale.name(); + QString name; + if (localeStr == "eo") { + name = "eo"; + } + else { + QLocale locale(localeStr); + name = locale.name(); + } // Attempt to find exact match int index = comboI18n->findData(name, Qt::UserRole); if (index < 0) { @@ -1492,7 +1505,6 @@ QString options_imp::languageToLocalizedString(const QLocale &locale) return QString::fromUtf8(C_LOCALE_ENGLISH_UNITEDKINGDOM); return QString::fromUtf8(C_LOCALE_ENGLISH); } - case QLocale::Esperanto: return QString::fromUtf8(C_LOCALE_ESPERANTO); case QLocale::French: return QString::fromUtf8(C_LOCALE_FRENCH); case QLocale::German: return QString::fromUtf8(C_LOCALE_GERMAN); case QLocale::Hungarian: return QString::fromUtf8(C_LOCALE_HUNGARIAN);