Browse Source

Expose new translations and improve language code.

adaptive-webui-19844
sledgehammer999 11 years ago
parent
commit
2b9f79fafe
  1. 2
      src/lang.qrc
  2. 4
      src/main.cpp
  3. 23
      src/preferences/options_imp.cpp
  4. 2
      src/preferences/options_imp.h
  5. 2
      src/src.pro
  6. 4
      src/webui/html/preferences_content.html
  7. 2
      src/webui/prefjson.cpp

2
src/lang.qrc

@ -9,6 +9,8 @@
<file>lang/qbittorrent_de.qm</file> <file>lang/qbittorrent_de.qm</file>
<file>lang/qbittorrent_el.qm</file> <file>lang/qbittorrent_el.qm</file>
<file>lang/qbittorrent_en.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_es.qm</file>
<file>lang/qbittorrent_eu.qm</file> <file>lang/qbittorrent_eu.qm</file>
<file>lang/qbittorrent_fi.qm</file> <file>lang/qbittorrent_fi.qm</file>

4
src/main.cpp

@ -260,13 +260,13 @@ int main(int argc, char *argv[]) {
)) { )) {
qDebug("Qt %s locale recognized, using translation.", qPrintable(locale)); qDebug("Qt %s locale recognized, using translation.", qPrintable(locale));
}else{ }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); app.installTranslator(&qtTranslator);
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));
} }
app.installTranslator(&translator); app.installTranslator(&translator);
#ifndef DISABLE_GUI #ifndef DISABLE_GUI

23
src/preferences/options_imp.cpp

@ -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;
} }

2
src/preferences/options_imp.h

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

2
src/src.pro

@ -210,6 +210,8 @@ TRANSLATIONS = $$LANG_PATH/qbittorrent_fr.ts \
$$LANG_PATH/qbittorrent_zh.ts \ $$LANG_PATH/qbittorrent_zh.ts \
$$LANG_PATH/qbittorrent_zh_TW.ts \ $$LANG_PATH/qbittorrent_zh_TW.ts \
$$LANG_PATH/qbittorrent_en.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_ca.ts \
$$LANG_PATH/qbittorrent_es.ts \ $$LANG_PATH/qbittorrent_es.ts \
$$LANG_PATH/qbittorrent_pl.ts \ $$LANG_PATH/qbittorrent_pl.ts \

4
src/webui/html/preferences_content.html

@ -270,7 +270,9 @@
<legend>_(Language)</legend> <legend>_(Language)</legend>
<label for="locale_select">_(User Interface Language:)</label> <label for="locale_select">_(User Interface Language:)</label>
<select id="locale_select"> <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="fr_FR">Français</option>
<option value="de_DE">Deutsch</option> <option value="de_DE">Deutsch</option>
<option value="hu_HU">Magyar</option> <option value="hu_HU">Magyar</option>

2
src/webui/prefjson.cpp

@ -155,7 +155,7 @@ void prefjson::setPreferences(const QString& json)
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);

Loading…
Cancel
Save