From 18c5f3ccf0ec3b3a56922b1b1a913df2a29d2d1a Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Tue, 3 May 2022 13:43:18 +0300 Subject: [PATCH] UI: Options: Show language names in English too --- src/ui/form/opt/pages/optionspage.cpp | 2 +- src/ui/manager/translationmanager.cpp | 10 ++++++---- src/ui/manager/translationmanager.h | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ui/form/opt/pages/optionspage.cpp b/src/ui/form/opt/pages/optionspage.cpp index 5b68274c..87f6bfb4 100644 --- a/src/ui/form/opt/pages/optionspage.cpp +++ b/src/ui/form/opt/pages/optionspage.cpp @@ -510,7 +510,7 @@ QLayout *OptionsPage::setupLangLayout() void OptionsPage::setupComboLanguage() { m_comboLanguage = - ControlUtil::createComboBox(translationManager()->naturalLabels(), [&](int index) { + ControlUtil::createComboBox(translationManager()->displayLabels(), [&](int index) { if (translationManager()->switchLanguage(index)) { iniUser()->setLanguage(translationManager()->localeName()); confManager()->saveIniUser(); diff --git a/src/ui/manager/translationmanager.cpp b/src/ui/manager/translationmanager.cpp index 588c1bac..8b16eba6 100644 --- a/src/ui/manager/translationmanager.cpp +++ b/src/ui/manager/translationmanager.cpp @@ -45,21 +45,23 @@ void TranslationManager::setupTranslation() m_translators.fill(nullptr); } -QStringList TranslationManager::naturalLabels() const +QStringList TranslationManager::displayLabels() const { QStringList list; list.reserve(m_locales.size()); int localeBit = 1; for (const QLocale &locale : m_locales) { - QString label = StringUtil::capitalize(locale.nativeLanguageName()); + QString label = QLocale::languageToString(locale.language()); + QString nativeLabel = StringUtil::capitalize(locale.nativeLanguageName()); if ((m_localesWithCountry & localeBit) != 0) { - label += " (" + StringUtil::capitalize(locale.nativeCountryName()) + ")"; + label += " (" + QLocale::countryToString(locale.country()) + ")"; + nativeLabel += " (" + StringUtil::capitalize(locale.nativeCountryName()) + ")"; } localeBit <<= 1; - list.append(label); + list.append(label + ", " + nativeLabel); } return list; } diff --git a/src/ui/manager/translationmanager.h b/src/ui/manager/translationmanager.h index e3e56e8b..9762ca0c 100644 --- a/src/ui/manager/translationmanager.h +++ b/src/ui/manager/translationmanager.h @@ -15,7 +15,6 @@ class TranslationManager : public QObject, public IocService { Q_OBJECT Q_PROPERTY(int language READ language WRITE switchLanguage NOTIFY languageChanged) - Q_PROPERTY(QStringList naturalLabels READ naturalLabels CONSTANT) public: explicit TranslationManager(QObject *parent = nullptr); @@ -25,7 +24,7 @@ public: int language() const { return m_language; } QString localeName() const { return m_locale.name(); } - QStringList naturalLabels() const; + QStringList displayLabels() const; int getLanguageByName(const QString &langName) const;