|
|
@ -279,8 +279,7 @@ void options_imp::initializeLanguageCombo() |
|
|
|
QString localeStr = lang_file.mid(12); // remove "qbittorrent_"
|
|
|
|
QString localeStr = lang_file.mid(12); // remove "qbittorrent_"
|
|
|
|
localeStr.chop(3); // Remove ".qm"
|
|
|
|
localeStr.chop(3); // Remove ".qm"
|
|
|
|
QLocale locale(localeStr); |
|
|
|
QLocale locale(localeStr); |
|
|
|
const QString country = locale.name().split("_").last().toLower(); |
|
|
|
QString language_name = languageToLocalizedString(locale); |
|
|
|
QString language_name = languageToLocalizedString(locale.language(), country); |
|
|
|
|
|
|
|
comboI18n->addItem(/*QIcon(":/Icons/flags/"+country+".png"), */language_name, locale.name()); |
|
|
|
comboI18n->addItem(/*QIcon(":/Icons/flags/"+country+".png"), */language_name, locale.name()); |
|
|
|
qDebug() << "Supported locale:" << locale.name(); |
|
|
|
qDebug() << "Supported locale:" << locale.name(); |
|
|
|
} |
|
|
|
} |
|
|
@ -361,7 +360,7 @@ void options_imp::saveOptions() { |
|
|
|
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) { |
|
|
|
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) { |
|
|
|
qDebug("%s locale recognized, using translation.", qPrintable(locale)); |
|
|
|
qDebug("%s locale recognized, using translation.", qPrintable(locale)); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale)); |
|
|
|
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale)); |
|
|
|
} |
|
|
|
} |
|
|
|
qApp->installTranslator(translator); |
|
|
|
qApp->installTranslator(translator); |
|
|
|
} |
|
|
|
} |
|
|
@ -1304,10 +1303,16 @@ void options_imp::handleIPFilterParsed(bool error, int ruleCount) |
|
|
|
disconnect(QBtSession::instance(), SIGNAL(ipFilterParsed(bool, int)), this, SLOT(handleIPFilterParsed(bool, int))); |
|
|
|
disconnect(QBtSession::instance(), SIGNAL(ipFilterParsed(bool, int)), this, SLOT(handleIPFilterParsed(bool, int))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString options_imp::languageToLocalizedString(QLocale::Language language, const QString& country) |
|
|
|
QString options_imp::languageToLocalizedString(const QLocale &locale) |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch(language) { |
|
|
|
switch(locale.language()) { |
|
|
|
case QLocale::English: return "English"; |
|
|
|
case QLocale::English: { |
|
|
|
|
|
|
|
if (locale.country() == QLocale::Australia) |
|
|
|
|
|
|
|
return "English(Australia)"; |
|
|
|
|
|
|
|
else if (locale.country() == QLocale::UnitedKingdom) |
|
|
|
|
|
|
|
return "English(United Kingdom)"; |
|
|
|
|
|
|
|
return "English"; |
|
|
|
|
|
|
|
} |
|
|
|
case QLocale::French: return QString::fromUtf8("Français"); |
|
|
|
case QLocale::French: return QString::fromUtf8("Français"); |
|
|
|
case QLocale::German: return QString::fromUtf8("Deutsch"); |
|
|
|
case QLocale::German: return QString::fromUtf8("Deutsch"); |
|
|
|
case QLocale::Hungarian: return QString::fromUtf8("Magyar"); |
|
|
|
case QLocale::Hungarian: return QString::fromUtf8("Magyar"); |
|
|
@ -1317,7 +1322,7 @@ QString options_imp::languageToLocalizedString(QLocale::Language language, const |
|
|
|
case QLocale::Catalan: return QString::fromUtf8("Català"); |
|
|
|
case QLocale::Catalan: return QString::fromUtf8("Català"); |
|
|
|
case QLocale::Galician: return QString::fromUtf8("Galego"); |
|
|
|
case QLocale::Galician: return QString::fromUtf8("Galego"); |
|
|
|
case QLocale::Portuguese: { |
|
|
|
case QLocale::Portuguese: { |
|
|
|
if (country == "br") |
|
|
|
if (locale.country() == QLocale::Brazil) |
|
|
|
return QString::fromUtf8("Português brasileiro"); |
|
|
|
return QString::fromUtf8("Português brasileiro"); |
|
|
|
return QString::fromUtf8("Português"); |
|
|
|
return QString::fromUtf8("Português"); |
|
|
|
} |
|
|
|
} |
|
|
@ -1346,14 +1351,14 @@ QString options_imp::languageToLocalizedString(QLocale::Language language, const |
|
|
|
case QLocale::Basque: return QString::fromUtf8("Euskara"); |
|
|
|
case QLocale::Basque: return QString::fromUtf8("Euskara"); |
|
|
|
case QLocale::Vietnamese: return QString::fromUtf8("tiếng Việt"); |
|
|
|
case QLocale::Vietnamese: return QString::fromUtf8("tiếng Việt"); |
|
|
|
case QLocale::Chinese: { |
|
|
|
case QLocale::Chinese: { |
|
|
|
if (country == "cn") |
|
|
|
if (locale.country() == QLocale::China) |
|
|
|
return QString::fromUtf8("中文 (简体)"); |
|
|
|
return QString::fromUtf8("中文 (简体)"); |
|
|
|
return QString::fromUtf8("中文 (繁體)"); |
|
|
|
return QString::fromUtf8("中文 (繁體)"); |
|
|
|
} |
|
|
|
} |
|
|
|
case QLocale::Korean: return QString::fromUtf8("한글"); |
|
|
|
case QLocale::Korean: return QString::fromUtf8("한글"); |
|
|
|
default: { |
|
|
|
default: { |
|
|
|
// Fallback to English
|
|
|
|
// Fallback to English
|
|
|
|
const QString eng_lang = QLocale::languageToString(language); |
|
|
|
const QString eng_lang = QLocale::languageToString(locale.language()); |
|
|
|
qWarning() << "Unrecognized language name: " << eng_lang; |
|
|
|
qWarning() << "Unrecognized language name: " << eng_lang; |
|
|
|
return eng_lang; |
|
|
|
return eng_lang; |
|
|
|
} |
|
|
|
} |
|
|
|