Commit c9c1dfbd authored by Simon Depiets's avatar Simon Depiets

Bump + Test + copy_if

parent e5d448ee
......@@ -44,6 +44,10 @@ class KLanguageNameTest : public QObject
Q_OBJECT
private Q_SLOTS:
void testListFound()
{
QVERIFY(KLanguageName::allLanguageCodes().count() > 0);
}
void testNameForCode()
{
// This is somewhat wrong, it should not say US.
......
......@@ -74,11 +74,10 @@ QStringList KLanguageName::allLanguageCodes()
const QString localeDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QStringLiteral("locale"), QStandardPaths::LocateDirectory);
const QStringList entries = QDir(localeDir).entryList(QDir::Dirs);
for (QStringList::const_iterator language = entries.constBegin(); language != entries.constEnd(); ++language) {
const QString entryFile = localeDir + '/' + *language + "/kf5_entry.desktop";
if (QFile::exists(entryFile)) {
systemLangList.append(*language);
}
}
std::copy_if(entries.begin(), entries.end(),
std::back_inserter(systemLangList),
[&localeDir](const QString &language) {
return QFile::exists(localeDir + '/' + language + "/kf5_entry.desktop");
});
return systemLangList;
}
......@@ -63,7 +63,7 @@ namespace KLanguageName
/**
* Returns the list of language codes found on the system.
*
* @since 5.73
* @since 5.74
*/
KCONFIGWIDGETS_EXPORT QStringList allLanguageCodes();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment