summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-11-15 22:02:44 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-23 23:35:38 +0100
commit9ca1e89e0d7e11b9db60d7fcf7399c655bd0e31e (patch)
tree97bc077f3589957cc099aa463cfc1d201bfd3dea
parent082efca145630db2d660d7241f7ae78d80f27e44 (diff)
rewrite support for listing translation files as sourcesv5.2.0-rc1
ts files listed among the sources now contribute extant source strings with locations, i.e., they are treated like all other sources. this basically makes it possible to use lupdate like gettext's msgmerge. this enables us to write a much more efficient variant of the split-qt-ts.pl script found in qttranslations. the original functionality of adding ts files as providers of additional translations to merge is hidden behind the new -xts flag; it is of course still undocumented. Change-Id: I7a5488d814f39d6b5e9053a414547a6b1461fc14 Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/linguist/lupdate/main.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/linguist/lupdate/main.cpp b/src/linguist/lupdate/main.cpp
index aa06e0b33..41eb7fbdf 100644
--- a/src/linguist/lupdate/main.cpp
+++ b/src/linguist/lupdate/main.cpp
@@ -519,6 +519,25 @@ static void excludeProjects(const ProFileEvaluator &visitor, QStringList *subPro
}
}
+static bool processTs(Translator &fetchedTor, const QString &file, ConversionData &cd)
+{
+ foreach (const Translator::FileFormat &fmt, Translator::registeredFileFormats()) {
+ if (file.endsWith(QLatin1Char('.') + fmt.extension, Qt::CaseInsensitive)) {
+ Translator tor;
+ if (tor.load(file, cd, fmt.extension)) {
+ foreach (TranslatorMessage msg, tor.messages()) {
+ msg.setType(TranslatorMessage::Unfinished);
+ msg.setTranslations(QStringList());
+ msg.setTranslatorComment(QString());
+ fetchedTor.extend(msg, cd);
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
static void processSources(Translator &fetchedTor,
const QStringList &sourceFiles, ConversionData &cd)
{
@@ -544,7 +563,7 @@ static void processSources(Translator &fetchedTor,
|| it->endsWith(QLatin1String(".qs"), Qt::CaseInsensitive))
requireQmlSupport = true;
#endif // QT_NO_QML
- else
+ else if (!processTs(fetchedTor, *it, cd))
sourceFilesCpp << *it;
}
@@ -747,6 +766,7 @@ int main(int argc, char **argv)
int proDebug = 0;
int numFiles = 0;
bool metTsFlag = false;
+ bool metXTsFlag = false;
bool recursiveScan = true;
QString extensions = m_defaultExtensions;
@@ -847,6 +867,11 @@ int main(int argc, char **argv)
return 0;
} else if (arg == QLatin1String("-ts")) {
metTsFlag = true;
+ metXTsFlag = false;
+ continue;
+ } else if (arg == QLatin1String("-xts")) {
+ metTsFlag = false;
+ metXTsFlag = true;
continue;
} else if (arg == QLatin1String("-extensions")) {
++i;
@@ -948,6 +973,8 @@ int main(int argc, char **argv)
}
}
numFiles++;
+ } else if (metXTsFlag) {
+ alienFiles += files;
} else {
foreach (const QString &file, files) {
QFileInfo fi(file);
@@ -999,17 +1026,10 @@ int main(int argc, char **argv)
}
}
} else {
- foreach (const Translator::FileFormat &fmt, Translator::registeredFileFormats()) {
- if (file.endsWith(QLatin1Char('.') + fmt.extension, Qt::CaseInsensitive)) {
- alienFiles << file;
- goto gotfile;
- }
- }
sourceFiles << QDir::cleanPath(fi.absoluteFilePath());;
projectRoots.insert(fi.absolutePath() + QLatin1Char('/'));
}
}
- gotfile:
numFiles++;
}
} // for args