mirror of
https://github.com/tnodir/fort
synced 2024-11-15 12:56:16 +00:00
UI: Options: Show languages with countries if needed.
This commit is contained in:
parent
d7e951f4f7
commit
e25cf2770b
@ -40,11 +40,14 @@ void TranslationManager::setupTranslation()
|
||||
const auto i18nFileInfos =
|
||||
QDir(i18nDir()).entryInfoList(QStringList() << ("*" TRANSLATION_FILE_SUFFIX));
|
||||
|
||||
int localeBit = 2;
|
||||
for (const QFileInfo &fileInfo : i18nFileInfos) {
|
||||
const QString localeName = fileInfo.completeBaseName().mid(prefixLen);
|
||||
const QLocale locale(localeName);
|
||||
|
||||
m_locales.append(locale);
|
||||
m_localesWithCountry |= localeName.size() > 2 ? localeBit : 0;
|
||||
localeBit <<= 1;
|
||||
}
|
||||
|
||||
// Translators will be loaded later when needed
|
||||
@ -57,8 +60,16 @@ QStringList TranslationManager::naturalLabels() const
|
||||
QStringList list;
|
||||
list.reserve(m_locales.size());
|
||||
|
||||
int localeBit = 1;
|
||||
for (const QLocale &locale : m_locales) {
|
||||
list.append(StringUtil::capitalize(locale.nativeLanguageName()));
|
||||
QString label = StringUtil::capitalize(locale.nativeLanguageName());
|
||||
|
||||
if ((m_localesWithCountry & localeBit) != 0) {
|
||||
label += " (" + StringUtil::capitalize(locale.nativeCountryName()) + ")";
|
||||
}
|
||||
localeBit <<= 1;
|
||||
|
||||
list.append(label);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ private:
|
||||
|
||||
QLocale m_locale;
|
||||
|
||||
quint32 m_localesWithCountry = 0;
|
||||
QVector<QLocale> m_locales;
|
||||
QVector<QTranslator *> m_translators;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user