mirror of
https://github.com/tnodir/fort
synced 2024-11-15 10:35:10 +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()
|
void OptionsPage::setupComboLanguage()
|
||||||
{
|
{
|
||||||
m_comboLanguage =
|
m_comboLanguage =
|
||||||
ControlUtil::createComboBox(translationManager()->naturalLabels(), [&](int index) {
|
ControlUtil::createComboBox(translationManager()->displayLabels(), [&](int index) {
|
||||||
if (translationManager()->switchLanguage(index)) {
|
if (translationManager()->switchLanguage(index)) {
|
||||||
iniUser()->setLanguage(translationManager()->localeName());
|
iniUser()->setLanguage(translationManager()->localeName());
|
||||||
confManager()->saveIniUser();
|
confManager()->saveIniUser();
|
||||||
|
@ -45,21 +45,23 @@ void TranslationManager::setupTranslation()
|
|||||||
m_translators.fill(nullptr);
|
m_translators.fill(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList TranslationManager::naturalLabels() const
|
QStringList TranslationManager::displayLabels() const
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
list.reserve(m_locales.size());
|
list.reserve(m_locales.size());
|
||||||
|
|
||||||
int localeBit = 1;
|
int localeBit = 1;
|
||||||
for (const QLocale &locale : m_locales) {
|
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) {
|
if ((m_localesWithCountry & localeBit) != 0) {
|
||||||
label += " (" + StringUtil::capitalize(locale.nativeCountryName()) + ")";
|
label += " (" + QLocale::countryToString(locale.country()) + ")";
|
||||||
|
nativeLabel += " (" + StringUtil::capitalize(locale.nativeCountryName()) + ")";
|
||||||
}
|
}
|
||||||
localeBit <<= 1;
|
localeBit <<= 1;
|
||||||
|
|
||||||
list.append(label);
|
list.append(label + ", " + nativeLabel);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ class TranslationManager : public QObject, public IocService
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int language READ language WRITE switchLanguage NOTIFY languageChanged)
|
Q_PROPERTY(int language READ language WRITE switchLanguage NOTIFY languageChanged)
|
||||||
Q_PROPERTY(QStringList naturalLabels READ naturalLabels CONSTANT)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TranslationManager(QObject *parent = nullptr);
|
explicit TranslationManager(QObject *parent = nullptr);
|
||||||
@ -25,7 +24,7 @@ public:
|
|||||||
int language() const { return m_language; }
|
int language() const { return m_language; }
|
||||||
QString localeName() const { return m_locale.name(); }
|
QString localeName() const { return m_locale.name(); }
|
||||||
|
|
||||||
QStringList naturalLabels() const;
|
QStringList displayLabels() const;
|
||||||
|
|
||||||
int getLanguageByName(const QString &langName) const;
|
int getLanguageByName(const QString &langName) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user