mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Fix selection of Esperanto locale. Closes #4999.
This commit is contained in:
parent
d721939d5f
commit
cef150eee6
@ -316,14 +316,21 @@ options_imp::options_imp(QWidget *parent)
|
|||||||
void options_imp::initializeLanguageCombo()
|
void options_imp::initializeLanguageCombo()
|
||||||
{
|
{
|
||||||
// List language files
|
// List language files
|
||||||
const QDir lang_dir(":/lang");
|
const QDir langDir(":/lang");
|
||||||
const QStringList lang_files = lang_dir.entryList(QStringList() << "qbittorrent_*.qm", QDir::Files);
|
const QStringList langFiles = langDir.entryList(QStringList("qbittorrent_*.qm"), QDir::Files);
|
||||||
foreach (QString lang_file, lang_files) {
|
foreach (const QString langFile, langFiles) {
|
||||||
QString localeStr = lang_file.mid(12); // remove "qbittorrent_"
|
QString localeStr = langFile.mid(12); // remove "qbittorrent_"
|
||||||
localeStr.chop(3); // Remove ".qm"
|
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);
|
QLocale locale(localeStr);
|
||||||
QString language_name = languageToLocalizedString(locale);
|
languageName = languageToLocalizedString(locale);
|
||||||
comboI18n->addItem(/*QIcon(":/icons/flags/"+country+".png"), */ language_name, localeStr);
|
}
|
||||||
|
comboI18n->addItem(/*QIcon(":/icons/flags/"+country+".png"), */ languageName, localeStr);
|
||||||
qDebug() << "Supported locale:" << localeStr;
|
qDebug() << "Supported locale:" << localeStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1217,8 +1224,14 @@ QString options_imp::getLocale() const
|
|||||||
|
|
||||||
void options_imp::setLocale(const QString &localeStr)
|
void options_imp::setLocale(const QString &localeStr)
|
||||||
{
|
{
|
||||||
|
QString name;
|
||||||
|
if (localeStr == "eo") {
|
||||||
|
name = "eo";
|
||||||
|
}
|
||||||
|
else {
|
||||||
QLocale locale(localeStr);
|
QLocale locale(localeStr);
|
||||||
QString name = locale.name();
|
name = locale.name();
|
||||||
|
}
|
||||||
// Attempt to find exact match
|
// Attempt to find exact match
|
||||||
int index = comboI18n->findData(name, Qt::UserRole);
|
int index = comboI18n->findData(name, Qt::UserRole);
|
||||||
if (index < 0) {
|
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_UNITEDKINGDOM);
|
||||||
return QString::fromUtf8(C_LOCALE_ENGLISH);
|
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::French: return QString::fromUtf8(C_LOCALE_FRENCH);
|
||||||
case QLocale::German: return QString::fromUtf8(C_LOCALE_GERMAN);
|
case QLocale::German: return QString::fromUtf8(C_LOCALE_GERMAN);
|
||||||
case QLocale::Hungarian: return QString::fromUtf8(C_LOCALE_HUNGARIAN);
|
case QLocale::Hungarian: return QString::fromUtf8(C_LOCALE_HUNGARIAN);
|
||||||
|
Loading…
Reference in New Issue
Block a user