diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-09-13 09:03:06 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-09-28 09:58:29 +0200 |
commit | db830ae43414a4882bd263641dad07b0b23811d7 (patch) | |
tree | 84d1fe14919228876285d07b5bfe0e1ab4294a7b /src/linguist | |
parent | 4b600512329ab595b5971ee79ee104db956f6129 (diff) | |
download | qttools-db830ae43414a4882bd263641dad07b0b23811d7.tar.gz |
lupdate: Parse .qrc files when using -project
Files in .qrc files were not taken into account when passing -project to
lupdate.
lupdate converts .pro files to .json files internally with the lprodump
tool. That tool already expanded .qrc files - that's why tst_lupdate
good:parseqrc succeeded.
Fixes: QTBUG-102282
Change-Id: Ib4cb2bfeb81eab7d165e6865629f69f951dc6492
Reviewed-by: Lucie Gerard <lucie.gerard@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/linguist')
-rw-r--r-- | src/linguist/lupdate/main.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/linguist/lupdate/main.cpp b/src/linguist/lupdate/main.cpp index d4e72ee4b..09794c8f5 100644 --- a/src/linguist/lupdate/main.cpp +++ b/src/linguist/lupdate/main.cpp @@ -476,6 +476,31 @@ static QStringList getResources(const QString &resourceFile) return rqr.files; } +// Remove .qrc files from the project and return them as absolute paths. +static QStringList extractQrcFiles(Project &project) +{ + auto it = project.sources.begin(); + QStringList qrcFiles; + while (it != project.sources.end()) { + QFileInfo fi(*it); + QString fn = QDir::cleanPath(fi.absoluteFilePath()); + if (fn.endsWith(QLatin1String(".qrc"), Qt::CaseInsensitive)) { + qrcFiles += fn; + it = project.sources.erase(it); + } else { + ++it; + } + } + return qrcFiles; +} + +// Replace all .qrc files in the project with their content. +static void expandQrcFiles(Project &project) +{ + for (const QString &qrcFile : extractQrcFiles(project)) + project.sources << getResources(qrcFile); +} + static bool processTs(Translator &fetchedTor, const QString &file, ConversionData &cd) { for (const Translator::FileFormat &fmt : qAsConst(Translator::registeredFileFormats())) { @@ -1036,6 +1061,8 @@ int main(int argc, char **argv) .arg(projectDescriptionFile)); return 1; } + for (Project &project : projectDescription) + expandQrcFiles(project); } bool fail = false; |