summaryrefslogtreecommitdiffstats
path: root/tools/linguist/lupdate/main.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-27 15:02:38 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-27 15:12:33 (GMT)
commit2a8fd7584590016dbe22fb74f440e71a2578dc81 (patch)
tree329a084df6ac72cd616530b4665989f7067c5c5f /tools/linguist/lupdate/main.cpp
parentb62b87d6ae3ced4466c1a1b085b51cec757e24f5 (diff)
downloadQt-2a8fd7584590016dbe22fb74f440e71a2578dc81.zip
Qt-2a8fd7584590016dbe22fb74f440e71a2578dc81.tar.gz
Qt-2a8fd7584590016dbe22fb74f440e71a2578dc81.tar.bz2
add -codecfortr option
this has always been kind of an omission ...
Diffstat (limited to 'tools/linguist/lupdate/main.cpp')
-rw-r--r--tools/linguist/lupdate/main.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp
index 6d91aa3..fd9c696 100644
--- a/tools/linguist/lupdate/main.cpp
+++ b/tools/linguist/lupdate/main.cpp
@@ -128,6 +128,8 @@ static void printUsage()
" -ts <ts-file>...\n"
" Specify the output file(s). This will override the TRANSLATIONS\n"
" and nullify the CODECFORTR from possibly specified project files.\n"
+ " -codecfortr <codec>\n"
+ " Specify the codec assumed for tr() calls. Effective only with -ts.\n"
" -version\n"
" Display the version of lupdate and exit.\n"
).arg(m_defaultExtensions));
@@ -405,6 +407,7 @@ int main(int argc, char **argv)
QStringList includePath;
QString targetLanguage;
QString sourceLanguage;
+ QByteArray codecForTr;
UpdateOptions options =
Verbose | // verbose is on by default starting with Qt 4.2
@@ -503,6 +506,14 @@ int main(int argc, char **argv)
} else if (arg == QLatin1String("-version")) {
printOut(QObject::tr("lupdate version %1\n").arg(QLatin1String(QT_VERSION_STR)));
return 0;
+ } else if (arg == QLatin1String("-codecfortr")) {
+ ++i;
+ if (i == argc) {
+ qWarning("The -codecfortr option should be followed by a codec name.");
+ return 1;
+ }
+ codecForTr = args[i].toLatin1();
+ continue;
} else if (arg == QLatin1String("-ts")) {
metTsFlag = true;
continue;
@@ -620,6 +631,8 @@ int main(int argc, char **argv)
if (!targetLanguage.isEmpty() && tsFileNames.count() != 1)
std::cerr << "lupdate warning: -target-language usually only "
"makes sense with exactly one TS file.\n";
+ if (!codecForTr.isEmpty() && tsFileNames.isEmpty())
+ std::cerr << "lupdate warning: -codecfortr has no effect without -ts.\n";
bool fail = false;
if (proFiles.isEmpty()) {
@@ -633,8 +646,9 @@ int main(int argc, char **argv)
cd.m_projectRoots = projectRoots;
cd.m_includePath = includePath;
cd.m_allCSources = allCSources;
+ fetchedTor.setCodecName(codecForTr);
processSources(fetchedTor, sourceFiles, cd);
- updateTsFiles(fetchedTor, tsFileNames, QByteArray(),
+ updateTsFiles(fetchedTor, tsFileNames, codecForTr,
sourceLanguage, targetLanguage, options, &fail);
} else {
if (!sourceFiles.isEmpty() || !includePath.isEmpty()) {
@@ -643,9 +657,10 @@ int main(int argc, char **argv)
}
if (!tsFileNames.isEmpty()) {
Translator fetchedTor;
+ fetchedTor.setCodecName(codecForTr);
processProjects(true, true, proFiles, options, QByteArray(),
targetLanguage, sourceLanguage, &fetchedTor, &fail);
- updateTsFiles(fetchedTor, tsFileNames, QByteArray(),
+ updateTsFiles(fetchedTor, tsFileNames, codecForTr,
sourceLanguage, targetLanguage, options, &fail);
} else {
processProjects(true, false, proFiles, options, QByteArray(),