mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
Fix the language selection in the combobox when the system locale only has a lang equivalent and not a lang_COUNTRY one. Closes #1786.
This commit is contained in:
parent
5d79fcdafd
commit
e5e22eb925
1 changed files with 13 additions and 4 deletions
|
@ -275,8 +275,8 @@ void options_imp::initializeLanguageCombo()
|
||||||
localeStr.chop(3); // Remove ".qm"
|
localeStr.chop(3); // Remove ".qm"
|
||||||
QLocale locale(localeStr);
|
QLocale locale(localeStr);
|
||||||
QString language_name = languageToLocalizedString(locale);
|
QString language_name = languageToLocalizedString(locale);
|
||||||
comboI18n->addItem(/*QIcon(":/Icons/flags/"+country+".png"), */language_name, locale.name());
|
comboI18n->addItem(/*QIcon(":/Icons/flags/"+country+".png"), */language_name, localeStr);
|
||||||
qDebug() << "Supported locale:" << locale.name();
|
qDebug() << "Supported locale:" << localeStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1026,10 +1026,19 @@ QString options_imp::getLocale() const {
|
||||||
|
|
||||||
void options_imp::setLocale(const QString &localeStr) {
|
void options_imp::setLocale(const QString &localeStr) {
|
||||||
QLocale locale(localeStr);
|
QLocale locale(localeStr);
|
||||||
|
QString name = locale.name();
|
||||||
// Attempt to find exact match
|
// Attempt to find exact match
|
||||||
int index = comboI18n->findData(locale.name(), Qt::UserRole);
|
int index = comboI18n->findData(name, Qt::UserRole);
|
||||||
if (index < 0 ) {
|
if (index < 0 ) {
|
||||||
// Unreconized, use US English
|
//Attempt to find a language match without a country
|
||||||
|
int pos = name.indexOf('_');
|
||||||
|
if (pos > -1) {
|
||||||
|
QString lang = name.left(pos);
|
||||||
|
index = comboI18n->findData(lang, Qt::UserRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index < 0) {
|
||||||
|
// Unrecognized, use US English
|
||||||
index = comboI18n->findData(QLocale("en").name(), Qt::UserRole);
|
index = comboI18n->findData(QLocale("en").name(), Qt::UserRole);
|
||||||
Q_ASSERT(index >= 0);
|
Q_ASSERT(index >= 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue