From 203aa70bdef14950b91d91b2e11ec99f5f580cd4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 27 Jan 2010 16:02:38 +0100 Subject: add -codecfortr option this has always been kind of an omission ... (cherry picked from commit 2a8fd7584590016dbe22fb74f440e71a2578dc81) --- tools/linguist/lupdate/main.cpp | 19 +++++++++++++++++-- 1 file 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 ...\n" " Specify the output file(s). This will override the TRANSLATIONS\n" " and nullify the CODECFORTR from possibly specified project files.\n" + " -codecfortr \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(), -- cgit v0.12