mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:25:20 +00:00
UI: Options: Show language names in English too
This commit is contained in:
parent
ce63520524
commit
18c5f3ccf0
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user