Translate locale names

This commit is contained in:
Christophe Dumez
2011-01-12 17:45:24 +00:00
parent 1f2e34b828
commit cdede2d3db
4 changed files with 58 additions and 3 deletions

View File

@@ -5,6 +5,7 @@
- I18N: Updated Greek, Croatian, Unkrainian and Bulgarian translations - I18N: Updated Greek, Croatian, Unkrainian and Bulgarian translations
- I18N: Added Armenian translation - I18N: Added Armenian translation
- I18N: Remove country flags from program preferences (language selection) - I18N: Remove country flags from program preferences (language selection)
- I18N: Translate locale names (language selection)
* Mon Jan 10 2011 - Christophe Dumez <chris@qbittorrent.org> - v2.6.1 * Mon Jan 10 2011 - Christophe Dumez <chris@qbittorrent.org> - v2.6.1
- BUGFIX: Really disable torrent addition dialog by default - BUGFIX: Really disable torrent addition dialog by default

View File

@@ -229,9 +229,9 @@ 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(); const QString country = locale.name().split("_").last().toLower();
QString language_name = QLocale::languageToString(locale.language()); 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();
} }
} }
@@ -1174,3 +1174,54 @@ void options_imp::handleIPFilterParsed(bool error, int ruleCount)
m_refreshingIpFilter = false; m_refreshingIpFilter = false;
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)
{
switch(language) {
case QLocale::English: return "English";
case QLocale::French: return QString::fromUtf8("Français");
case QLocale::German: return QString::fromUtf8("Deutsch");
case QLocale::Hungarian: return QString::fromUtf8("Magyar");
case QLocale::Italian: return QString::fromUtf8("Italiano");
case QLocale::Dutch: return QString::fromUtf8("Nederlands");
case QLocale::Spanish: return QString::fromUtf8("Español");
case QLocale::Catalan: return QString::fromUtf8("Català");
case QLocale::Galician: return QString::fromUtf8("Galego");
case QLocale::Portuguese: {
if(country == "br")
return QString::fromUtf8("Português brasileiro");
return QString::fromUtf8("Português");
}
case QLocale::Polish: return QString::fromUtf8("Polski");
case QLocale::Czech: return QString::fromUtf8("Čeština");
case QLocale::Slovak: return QString::fromUtf8("Slovenčina");
case QLocale::Serbian: return QString::fromUtf8("Српски");
case QLocale::Croatian: return QString::fromUtf8("Hrvatski");
case QLocale::Armenian: return QString::fromUtf8("Հայերեն");
case QLocale::Romanian: return QString::fromUtf8("Română");
case QLocale::Turkish: return QString::fromUtf8("Türkçe");
case QLocale::Greek: return QString::fromUtf8("Ελληνικά");
case QLocale::Swedish: return QString::fromUtf8("Svenska");
case QLocale::Finnish: return QString::fromUtf8("Suomi");
case QLocale::Norwegian: return QString::fromUtf8("Norsk");
case QLocale::Danish: return QString::fromUtf8("Dansk");
case QLocale::Bulgarian: return QString::fromUtf8("Български");
case QLocale::Ukrainian: return QString::fromUtf8("Українська");
case QLocale::Russian: return QString::fromUtf8("Русский");
case QLocale::Japanese: return QString::fromUtf8("日本語");
case QLocale::Arabic: return QString::fromUtf8("عربي");
case QLocale::Chinese: {
if(country == "cn")
return QString::fromUtf8("中文 (简体)");
return QString::fromUtf8("中文 (繁體)");
}
case QLocale::Korean: return QString::fromUtf8("한글");
default: {
// Fallback to English
const QString eng_lang = QLocale::languageToString(language);
qWarning() << "Unrecognized language name: " << eng_lang;
return eng_lang;
}
}
}

View File

@@ -97,6 +97,7 @@ private:
void saveOptions(); void saveOptions();
void loadOptions(); void loadOptions();
void initializeLanguageCombo(); void initializeLanguageCombo();
static QString languageToLocalizedString(QLocale::Language language, const QString& country);
// General options // General options
QString getLocale() const; QString getLocale() const;
QString getStyle() const; QString getStyle() const;

View File

@@ -200,6 +200,7 @@
<option value="en_GB">English</option> <option value="en_GB">English</option>
<option value="fr_FR">Français</option> <option value="fr_FR">Français</option>
<option value="de_DE">Deutsch</option> <option value="de_DE">Deutsch</option>
<option value="ar_AR">عربي</option>
<option value="hu_HU">Magyar</option> <option value="hu_HU">Magyar</option>
<option value="it_IT">Italiano</option> <option value="it_IT">Italiano</option>
<option value="nl_NL">Nederlands</option> <option value="nl_NL">Nederlands</option>
@@ -212,6 +213,7 @@
<option value="cs_CZ">Čeština</option> <option value="cs_CZ">Čeština</option>
<option value="sk_SK">Slovenčina</option> <option value="sk_SK">Slovenčina</option>
<option value="sr_CS">Српски</option> <option value="sr_CS">Српски</option>
<option value="hr_HR">Hrvatski</option>
<option value="hy_AM">Հայերեն</option> <option value="hy_AM">Հայերեն</option>
<option value="ro_RO">Română</option> <option value="ro_RO">Română</option>
<option value="tr_TR">Türkçe</option> <option value="tr_TR">Türkçe</option>