diff options
Diffstat (limited to 'src/plugins/projectexplorer')
-rw-r--r-- | src/plugins/projectexplorer/project.cpp | 15 | ||||
-rw-r--r-- | src/plugins/projectexplorer/project.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index e7e6599ed9..254ac123bf 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -983,6 +983,21 @@ QVariant Project::extraData(const QString &key) const return d->m_extraData.value(key); } +QStringList Project::availableQmlPreviewTranslations(QString *errorMessage) +{ + const auto projectDirectory = rootProjectDirectory().toFileInfo().absoluteFilePath(); + const QDir languageDirectory(projectDirectory + "/i18n"); + const auto qmFiles = languageDirectory.entryList({"qml_*.qm"}); + if (qmFiles.isEmpty() && errorMessage) + errorMessage->append(tr("Could not find any qml_*.qm file at '%1'").arg(languageDirectory.absolutePath())); + return Utils::transform(qmFiles, [](const QString &qmFile) { + const int localeStartPosition = qmFile.lastIndexOf("_") + 1; + const int localeEndPosition = qmFile.size() - QString(".qm").size(); + const QString locale = qmFile.left(localeEndPosition).mid(localeStartPosition); + return locale; + }); +} + #if defined(WITH_TESTS) } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index b6b65e6889..58d6a914b8 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -173,6 +173,8 @@ public: void setExtraData(const QString &key, const QVariant &data); QVariant extraData(const QString &key) const; + QStringList availableQmlPreviewTranslations(QString *errorMessage); + signals: void projectFileIsDirty(const Utils::FilePath &path); |