Browse Source

Fix selection of Esperanto locale. Closes #4999.

adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
cef150eee6
  1. 28
      src/gui/options_imp.cpp

28
src/gui/options_imp.cpp

@ -316,14 +316,21 @@ options_imp::options_imp(QWidget *parent) @@ -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"
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);
QString language_name = languageToLocalizedString(locale);
comboI18n->addItem(/*QIcon(":/icons/flags/"+country+".png"), */ language_name, 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 @@ -1217,8 +1224,14 @@ QString options_imp::getLocale() const
void options_imp::setLocale(const QString &localeStr)
{
QString name;
if (localeStr == "eo") {
name = "eo";
}
else {
QLocale locale(localeStr);
QString name = locale.name();
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) @@ -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);

Loading…
Cancel
Save