Expose new translations and improve language code.

This commit is contained in:
sledgehammer999 2013-10-20 19:31:01 +03:00
parent 88c64ccf0a
commit 2b9f79fafe
7 changed files with 26 additions and 15 deletions

View file

@ -9,6 +9,8 @@
<file>lang/qbittorrent_de.qm</file>
<file>lang/qbittorrent_el.qm</file>
<file>lang/qbittorrent_en.qm</file>
<file>lang/qbittorrent_en_AU.qm</file>
<file>lang/qbittorrent_en_GB.qm</file>
<file>lang/qbittorrent_es.qm</file>
<file>lang/qbittorrent_eu.qm</file>
<file>lang/qbittorrent_fi.qm</file>

View file

@ -260,13 +260,13 @@ int main(int argc, char *argv[]) {
)) {
qDebug("Qt %s locale recognized, using translation.", qPrintable(locale));
}else{
qDebug("Qt %s locale unrecognized, using default (en_GB).", qPrintable(locale));
qDebug("Qt %s locale unrecognized, using default (en).", qPrintable(locale));
}
app.installTranslator(&qtTranslator);
if (translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
}else{
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
}
app.installTranslator(&translator);
#ifndef DISABLE_GUI

View file

@ -278,9 +278,8 @@ void options_imp::initializeLanguageCombo()
foreach (QString lang_file, lang_files) {
QString localeStr = lang_file.mid(12); // remove "qbittorrent_"
localeStr.chop(3); // Remove ".qm"
QLocale locale(localeStr);
const QString country = locale.name().split("_").last().toLower();
QString language_name = languageToLocalizedString(locale.language(), country);
QLocale locale(localeStr);
QString language_name = languageToLocalizedString(locale);
comboI18n->addItem(/*QIcon(":/Icons/flags/"+country+".png"), */language_name, locale.name());
qDebug() << "Supported locale:" << locale.name();
}
@ -361,7 +360,7 @@ void options_imp::saveOptions() {
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
}else{
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
}
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)));
}
QString options_imp::languageToLocalizedString(QLocale::Language language, const QString& country)
QString options_imp::languageToLocalizedString(const QLocale &locale)
{
switch(language) {
case QLocale::English: return "English";
switch(locale.language()) {
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::German: return QString::fromUtf8("Deutsch");
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::Galician: return QString::fromUtf8("Galego");
case QLocale::Portuguese: {
if (country == "br")
if (locale.country() == QLocale::Brazil)
return QString::fromUtf8("Português brasileiro");
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::Vietnamese: return QString::fromUtf8("tiếng Việt");
case QLocale::Chinese: {
if (country == "cn")
if (locale.country() == QLocale::China)
return QString::fromUtf8("中文 (简体)");
return QString::fromUtf8("中文 (繁體)");
}
case QLocale::Korean: return QString::fromUtf8("한글");
default: {
// Fallback to English
const QString eng_lang = QLocale::languageToString(language);
const QString eng_lang = QLocale::languageToString(locale.language());
qWarning() << "Unrecognized language name: " << eng_lang;
return eng_lang;
}

View file

@ -92,7 +92,7 @@ private:
void saveOptions();
void loadOptions();
void initializeLanguageCombo();
static QString languageToLocalizedString(QLocale::Language language, const QString& country);
static QString languageToLocalizedString(const QLocale &locale);
// General options
QString getLocale() const;
bool systrayIntegration() const;

View file

@ -210,6 +210,8 @@ TRANSLATIONS = $$LANG_PATH/qbittorrent_fr.ts \
$$LANG_PATH/qbittorrent_zh.ts \
$$LANG_PATH/qbittorrent_zh_TW.ts \
$$LANG_PATH/qbittorrent_en.ts \
$$LANG_PATH/qbittorrent_en_AU.ts \
$$LANG_PATH/qbittorrent_en_GB.ts \
$$LANG_PATH/qbittorrent_ca.ts \
$$LANG_PATH/qbittorrent_es.ts \
$$LANG_PATH/qbittorrent_pl.ts \

View file

@ -270,7 +270,9 @@
<legend>_(Language)</legend>
<label for="locale_select">_(User Interface Language:)</label>
<select id="locale_select">
<option value="en_GB">English</option>
<option value="en">English</option>
<option value="en_AU">English(Australia)</option>
<option value="en_GB">English(United Kingdom)</option>
<option value="fr_FR">Français</option>
<option value="de_DE">Deutsch</option>
<option value="hu_HU">Magyar</option>

View file

@ -155,7 +155,7 @@ void prefjson::setPreferences(const QString& json)
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
}else{
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
}
qApp->installTranslator(translator);