Browse Source

Merge pull request #12420 from Chocobo1/locale

Sort locale language list
adaptive-webui-19844
Mike Tzou 5 years ago committed by GitHub
parent
commit
3021b99a50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 68
      src/base/unicodestrings.h
  2. 142
      src/gui/optionsdialog.cpp
  3. 1
      src/gui/optionsdialog.h

68
src/base/unicodestrings.h

@ -36,58 +36,60 @@ @@ -36,58 +36,60 @@
// Because of the poor handling of UTF-8 characters in MSVC (emits warning C4819),
// we put all problematic UTF-8 chars/strings in this file.
// See issue #3059 for more details (https://github.com/qbittorrent/qBittorrent/issues/3059).
const char C_INFINITY[] = "";
const char C_NON_BREAKING_SPACE[] = " ";
const char C_COPYRIGHT[] = "©";
const char C_INFINITY[] = "";
const char C_NON_BREAKING_SPACE[] = " ";
const char C_THIN_SPACE[] = "";
const char C_UTP[] = "μTP";
const char C_LOCALE_ARABIC[] = "عربي";
const char C_LOCALE_ARMENIAN[] = "Հայերեն";
const char C_LOCALE_BASQUE[] = "Euskara";
const char C_LOCALE_BULGARIAN[] = "Български";
const char C_LOCALE_BYELORUSSIAN[] = "Беларуская";
const char C_LOCALE_CATALAN[] = "Català";
const char C_LOCALE_CHINESE_SIMPLIFIED[] = "简体中文";
const char C_LOCALE_CHINESE_TRADITIONAL_HK[] = "香港正體字";
const char C_LOCALE_CHINESE_TRADITIONAL_TW[] = "正體中文";
const char C_LOCALE_CROATIAN[] = "Hrvatski";
const char C_LOCALE_CZECH[] = "Čeština";
const char C_LOCALE_DANISH[] = "Dansk";
const char C_LOCALE_DUTCH[] = "Nederlands";
const char C_LOCALE_ENGLISH[] = "English";
const char C_LOCALE_ENGLISH_AUSTRALIA[] = "English(Australia)";
const char C_LOCALE_ENGLISH_UNITEDKINGDOM[] = "English(United Kingdom)";
const char C_LOCALE_ESPERANTO[] = "Esperanto";
const char C_LOCALE_FINNISH[] = "Suomi";
const char C_LOCALE_FRENCH[] = "Français";
const char C_LOCALE_GALICIAN[] = "Galego";
const char C_LOCALE_GEORGIAN[] = "ქართული";
const char C_LOCALE_GERMAN[] = "Deutsch";
const char C_LOCALE_GREEK[] = "Ελληνικά";
const char C_LOCALE_HEBREW[] = "עברית";
const char C_LOCALE_HINDI[] = "ि, हि";
const char C_LOCALE_HUNGARIAN[] = "Magyar";
const char C_LOCALE_ICELANDIC[] = "Íslenska";
const char C_LOCALE_INDONESIAN[] = "Bahasa Indonesia";
const char C_LOCALE_ITALIAN[] = "Italiano";
const char C_LOCALE_DUTCH[] = "Nederlands";
const char C_LOCALE_SPANISH[] = "Español";
const char C_LOCALE_CATALAN[] = "Català";
const char C_LOCALE_GALICIAN[] = "Galego";
const char C_LOCALE_OCCITAN[] = "lenga d'òc";
const char C_LOCALE_PORTUGUESE[] = "Português";
const char C_LOCALE_PORTUGUESE_BRAZIL[] = "Português brasileiro";
const char C_LOCALE_POLISH[] = "Polski";
const char C_LOCALE_JAPANESE[] = "日本語";
const char C_LOCALE_KOREAN[] = "한글";
const char C_LOCALE_LATVIAN[] = "latviešu valoda";
const char C_LOCALE_LITHUANIAN[] = "Lietuvių";
const char C_LOCALE_MALAY[] = "بهاس ملايو";
const char C_LOCALE_CZECH[] = "Čeština";
const char C_LOCALE_NORWEGIAN[] = "Norsk";
const char C_LOCALE_OCCITAN[] = "lenga d'òc";
const char C_LOCALE_POLISH[] = "Polski";
const char C_LOCALE_PORTUGUESE[] = "Português";
const char C_LOCALE_PORTUGUESE_BRAZIL[] = "Português brasileiro";
const char C_LOCALE_ROMANIAN[] = "Română";
const char C_LOCALE_RUSSIAN[] = "Русский";
const char C_LOCALE_SERBIAN[] = "Српски";
const char C_LOCALE_SLOVAK[] = "Slovenčina";
const char C_LOCALE_SLOVENIAN[] = "Slovenščina";
const char C_LOCALE_SERBIAN[] = "Српски";
const char C_LOCALE_CROATIAN[] = "Hrvatski";
const char C_LOCALE_ARMENIAN[] = "Հայերեն";
const char C_LOCALE_ROMANIAN[] = "Română";
const char C_LOCALE_TURKISH[] = "Türkçe";
const char C_LOCALE_GREEK[] = "Ελληνικά";
const char C_LOCALE_SPANISH[] = "Español";
const char C_LOCALE_SWEDISH[] = "Svenska";
const char C_LOCALE_FINNISH[] = "Suomi";
const char C_LOCALE_NORWEGIAN[] = "Norsk";
const char C_LOCALE_DANISH[] = "Dansk";
const char C_LOCALE_BULGARIAN[] = "Български";
const char C_LOCALE_TURKISH[] = "Türkçe";
const char C_LOCALE_UKRAINIAN[] = "Українська";
const char C_LOCALE_UZBEK[] = "أۇزبېك";
const char C_LOCALE_RUSSIAN[] = "Русский";
const char C_LOCALE_JAPANESE[] = "日本語";
const char C_LOCALE_HEBREW[] = "עברית";
const char C_LOCALE_HINDI[] = "ि, हि";
const char C_LOCALE_ARABIC[] = "عربي";
const char C_LOCALE_GEORGIAN[] = "ქართული";
const char C_LOCALE_BYELORUSSIAN[] = "Беларуская";
const char C_LOCALE_BASQUE[] = "Euskara";
const char C_LOCALE_VIETNAMESE[] = "tiếng Việt";
const char C_LOCALE_CHINESE_TRADITIONAL_TW[] = "正體中文";
const char C_LOCALE_CHINESE_TRADITIONAL_HK[] = "香港正體字";
const char C_LOCALE_CHINESE_SIMPLIFIED[] = "简体中文";
const char C_LOCALE_KOREAN[] = "한글";

142
src/gui/optionsdialog.cpp

@ -81,6 +81,73 @@ namespace @@ -81,6 +81,73 @@ namespace
ret.append(locale.toString(date.addDays(i), "dddd"));
return ret;
}
QString languageToLocalizedString(const QLocale &locale)
{
switch (locale.language()) {
case QLocale::Arabic: return QString::fromUtf8(C_LOCALE_ARABIC);
case QLocale::Armenian: return QString::fromUtf8(C_LOCALE_ARMENIAN);
case QLocale::Basque: return QString::fromUtf8(C_LOCALE_BASQUE);
case QLocale::Bulgarian: return QString::fromUtf8(C_LOCALE_BULGARIAN);
case QLocale::Byelorussian: return QString::fromUtf8(C_LOCALE_BYELORUSSIAN);
case QLocale::Catalan: return QString::fromUtf8(C_LOCALE_CATALAN);
case QLocale::Chinese:
switch (locale.country()) {
case QLocale::China: return QString::fromUtf8(C_LOCALE_CHINESE_SIMPLIFIED);
case QLocale::HongKong: return QString::fromUtf8(C_LOCALE_CHINESE_TRADITIONAL_HK);
default: return QString::fromUtf8(C_LOCALE_CHINESE_TRADITIONAL_TW);
}
case QLocale::Croatian: return QString::fromUtf8(C_LOCALE_CROATIAN);
case QLocale::Czech: return QString::fromUtf8(C_LOCALE_CZECH);
case QLocale::Danish: return QString::fromUtf8(C_LOCALE_DANISH);
case QLocale::Dutch: return QString::fromUtf8(C_LOCALE_DUTCH);
case QLocale::English:
switch (locale.country()) {
case QLocale::Australia: return QString::fromUtf8(C_LOCALE_ENGLISH_AUSTRALIA);
case QLocale::UnitedKingdom: return QString::fromUtf8(C_LOCALE_ENGLISH_UNITEDKINGDOM);
default: return QString::fromUtf8(C_LOCALE_ENGLISH);
}
case QLocale::Finnish: return QString::fromUtf8(C_LOCALE_FINNISH);
case QLocale::French: return QString::fromUtf8(C_LOCALE_FRENCH);
case QLocale::Galician: return QString::fromUtf8(C_LOCALE_GALICIAN);
case QLocale::Georgian: return QString::fromUtf8(C_LOCALE_GEORGIAN);
case QLocale::German: return QString::fromUtf8(C_LOCALE_GERMAN);
case QLocale::Greek: return QString::fromUtf8(C_LOCALE_GREEK);
case QLocale::Hebrew: return QString::fromUtf8(C_LOCALE_HEBREW);
case QLocale::Hindi: return QString::fromUtf8(C_LOCALE_HINDI);
case QLocale::Hungarian: return QString::fromUtf8(C_LOCALE_HUNGARIAN);
case QLocale::Icelandic: return QString::fromUtf8(C_LOCALE_ICELANDIC);
case QLocale::Indonesian: return QString::fromUtf8(C_LOCALE_INDONESIAN);
case QLocale::Italian: return QString::fromUtf8(C_LOCALE_ITALIAN);
case QLocale::Japanese: return QString::fromUtf8(C_LOCALE_JAPANESE);
case QLocale::Korean: return QString::fromUtf8(C_LOCALE_KOREAN);
case QLocale::Latvian: return QString::fromUtf8(C_LOCALE_LATVIAN);
case QLocale::Lithuanian: return QString::fromUtf8(C_LOCALE_LITHUANIAN);
case QLocale::Malay: return QString::fromUtf8(C_LOCALE_MALAY);
case QLocale::Norwegian: return QString::fromUtf8(C_LOCALE_NORWEGIAN);
case QLocale::Occitan: return QString::fromUtf8(C_LOCALE_OCCITAN);
case QLocale::Polish: return QString::fromUtf8(C_LOCALE_POLISH);
case QLocale::Portuguese:
if (locale.country() == QLocale::Brazil)
return QString::fromUtf8(C_LOCALE_PORTUGUESE_BRAZIL);
return QString::fromUtf8(C_LOCALE_PORTUGUESE);
case QLocale::Romanian: return QString::fromUtf8(C_LOCALE_ROMANIAN);
case QLocale::Russian: return QString::fromUtf8(C_LOCALE_RUSSIAN);
case QLocale::Serbian: return QString::fromUtf8(C_LOCALE_SERBIAN);
case QLocale::Slovak: return QString::fromUtf8(C_LOCALE_SLOVAK);
case QLocale::Slovenian: return QString::fromUtf8(C_LOCALE_SLOVENIAN);
case QLocale::Spanish: return QString::fromUtf8(C_LOCALE_SPANISH);
case QLocale::Swedish: return QString::fromUtf8(C_LOCALE_SWEDISH);
case QLocale::Turkish: return QString::fromUtf8(C_LOCALE_TURKISH);
case QLocale::Ukrainian: return QString::fromUtf8(C_LOCALE_UKRAINIAN);
case QLocale::Uzbek: return QString::fromUtf8(C_LOCALE_UZBEK);
case QLocale::Vietnamese: return QString::fromUtf8(C_LOCALE_VIETNAMESE);
default:
const QString lang = QLocale::languageToString(locale.language());
qWarning() << "Unrecognized language name: " << lang;
return lang;
}
}
}
class WheelEventEater : public QObject
@ -1698,81 +1765,6 @@ void OptionsDialog::handleIPFilterParsed(bool error, int ruleCount) @@ -1698,81 +1765,6 @@ void OptionsDialog::handleIPFilterParsed(bool error, int ruleCount)
disconnect(BitTorrent::Session::instance(), &BitTorrent::Session::IPFilterParsed, this, &OptionsDialog::handleIPFilterParsed);
}
QString OptionsDialog::languageToLocalizedString(const QLocale &locale)
{
switch (locale.language()) {
case QLocale::English: {
if (locale.country() == QLocale::Australia)
return QString::fromUtf8(C_LOCALE_ENGLISH_AUSTRALIA);
if (locale.country() == QLocale::UnitedKingdom)
return QString::fromUtf8(C_LOCALE_ENGLISH_UNITEDKINGDOM);
return QString::fromUtf8(C_LOCALE_ENGLISH);
}
case QLocale::French: return QString::fromUtf8(C_LOCALE_FRENCH);
case QLocale::German: return QString::fromUtf8(C_LOCALE_GERMAN);
case QLocale::Hungarian: return QString::fromUtf8(C_LOCALE_HUNGARIAN);
case QLocale::Icelandic: return QString::fromUtf8(C_LOCALE_ICELANDIC);
case QLocale::Indonesian: return QString::fromUtf8(C_LOCALE_INDONESIAN);
case QLocale::Italian: return QString::fromUtf8(C_LOCALE_ITALIAN);
case QLocale::Dutch: return QString::fromUtf8(C_LOCALE_DUTCH);
case QLocale::Spanish: return QString::fromUtf8(C_LOCALE_SPANISH);
case QLocale::Catalan: return QString::fromUtf8(C_LOCALE_CATALAN);
case QLocale::Galician: return QString::fromUtf8(C_LOCALE_GALICIAN);
case QLocale::Occitan: return QString::fromUtf8(C_LOCALE_OCCITAN);
case QLocale::Portuguese: {
if (locale.country() == QLocale::Brazil)
return QString::fromUtf8(C_LOCALE_PORTUGUESE_BRAZIL);
return QString::fromUtf8(C_LOCALE_PORTUGUESE);
}
case QLocale::Polish: return QString::fromUtf8(C_LOCALE_POLISH);
case QLocale::Latvian: return QString::fromUtf8(C_LOCALE_LATVIAN);
case QLocale::Lithuanian: return QString::fromUtf8(C_LOCALE_LITHUANIAN);
case QLocale::Malay: return QString::fromUtf8(C_LOCALE_MALAY);
case QLocale::Czech: return QString::fromUtf8(C_LOCALE_CZECH);
case QLocale::Slovak: return QString::fromUtf8(C_LOCALE_SLOVAK);
case QLocale::Slovenian: return QString::fromUtf8(C_LOCALE_SLOVENIAN);
case QLocale::Serbian: return QString::fromUtf8(C_LOCALE_SERBIAN);
case QLocale::Croatian: return QString::fromUtf8(C_LOCALE_CROATIAN);
case QLocale::Armenian: return QString::fromUtf8(C_LOCALE_ARMENIAN);
case QLocale::Romanian: return QString::fromUtf8(C_LOCALE_ROMANIAN);
case QLocale::Turkish: return QString::fromUtf8(C_LOCALE_TURKISH);
case QLocale::Greek: return QString::fromUtf8(C_LOCALE_GREEK);
case QLocale::Swedish: return QString::fromUtf8(C_LOCALE_SWEDISH);
case QLocale::Finnish: return QString::fromUtf8(C_LOCALE_FINNISH);
case QLocale::Norwegian: return QString::fromUtf8(C_LOCALE_NORWEGIAN);
case QLocale::Danish: return QString::fromUtf8(C_LOCALE_DANISH);
case QLocale::Bulgarian: return QString::fromUtf8(C_LOCALE_BULGARIAN);
case QLocale::Ukrainian: return QString::fromUtf8(C_LOCALE_UKRAINIAN);
case QLocale::Uzbek: return QString::fromUtf8(C_LOCALE_UZBEK);
case QLocale::Russian: return QString::fromUtf8(C_LOCALE_RUSSIAN);
case QLocale::Japanese: return QString::fromUtf8(C_LOCALE_JAPANESE);
case QLocale::Hebrew: return QString::fromUtf8(C_LOCALE_HEBREW);
case QLocale::Hindi: return QString::fromUtf8(C_LOCALE_HINDI);
case QLocale::Arabic: return QString::fromUtf8(C_LOCALE_ARABIC);
case QLocale::Georgian: return QString::fromUtf8(C_LOCALE_GEORGIAN);
case QLocale::Byelorussian: return QString::fromUtf8(C_LOCALE_BYELORUSSIAN);
case QLocale::Basque: return QString::fromUtf8(C_LOCALE_BASQUE);
case QLocale::Vietnamese: return QString::fromUtf8(C_LOCALE_VIETNAMESE);
case QLocale::Chinese: {
switch (locale.country()) {
case QLocale::China:
return QString::fromUtf8(C_LOCALE_CHINESE_SIMPLIFIED);
case QLocale::HongKong:
return QString::fromUtf8(C_LOCALE_CHINESE_TRADITIONAL_HK);
default:
return QString::fromUtf8(C_LOCALE_CHINESE_TRADITIONAL_TW);
}
}
case QLocale::Korean: return QString::fromUtf8(C_LOCALE_KOREAN);
default: {
// Fallback to English
const QString engLang = QLocale::languageToString(locale.language());
qWarning() << "Unrecognized language name: " << engLang;
return engLang;
}
}
}
bool OptionsDialog::schedTimesOk()
{
if (m_ui->timeEditScheduleFrom->time() == m_ui->timeEditScheduleTo->time()) {

1
src/gui/optionsdialog.h

@ -117,7 +117,6 @@ private: @@ -117,7 +117,6 @@ private:
void saveOptions();
void loadOptions();
void initializeLanguageCombo();
static QString languageToLocalizedString(const QLocale &locale);
// General options
QString getLocale() const;
#ifndef Q_OS_MACOS

Loading…
Cancel
Save