summaryrefslogtreecommitdiffstats
path: root/tools/linguist
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-27 17:48:26 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-27 17:49:42 (GMT)
commita4538a2532582f4bb1b6e85ed1e125f9c68bb251 (patch)
tree57cb24a3c23abe9298d73bb4a8fe2bc1466b33da /tools/linguist
parent22144848655620adf9c5c8fd1abdbbbfef07069e (diff)
downloadQt-a4538a2532582f4bb1b6e85ed1e125f9c68bb251.zip
Qt-a4538a2532582f4bb1b6e85ed1e125f9c68bb251.tar.gz
Qt-a4538a2532582f4bb1b6e85ed1e125f9c68bb251.tar.bz2
don't falsely complain about mismatched codecfortr
normalize the user input first
Diffstat (limited to 'tools/linguist')
-rw-r--r--tools/linguist/lupdate/main.cpp26
-rw-r--r--tools/linguist/shared/translator.h1
2 files changed, 14 insertions, 13 deletions
diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp
index a50c97a..b2bfd7c 100644
--- a/tools/linguist/lupdate/main.cpp
+++ b/tools/linguist/lupdate/main.cpp
@@ -136,7 +136,7 @@ static void printUsage()
}
static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFileNames,
- const QByteArray &codecForTr, const QString &sourceLanguage, const QString &targetLanguage,
+ bool setCodec, const QString &sourceLanguage, const QString &targetLanguage,
UpdateOptions options, bool *fail)
{
QDir dir;
@@ -154,10 +154,10 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil
}
tor.resolveDuplicates();
cd.clearErrors();
- if (!codecForTr.isEmpty() && codecForTr != tor.codecName())
+ if (setCodec && fetchedTor.codec() != tor.codec())
qWarning("lupdate warning: Codec for tr() '%s' disagrees with "
"existing file's codec '%s'. Expect trouble.",
- codecForTr.constData(), tor.codecName().constData());
+ fetchedTor.codecName().constData(), tor.codecName().constData());
if (!targetLanguage.isEmpty() && targetLanguage != tor.languageCode())
qWarning("lupdate warning: Specified target language '%s' disagrees with "
"existing file's language '%s'. Ignoring.",
@@ -167,8 +167,8 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil
"existing file's language '%s'. Ignoring.",
qPrintable(sourceLanguage), qPrintable(tor.sourceLanguageCode()));
} else {
- if (!codecForTr.isEmpty())
- tor.setCodecName(codecForTr);
+ if (setCodec)
+ tor.setCodec(fetchedTor.codec());
if (!targetLanguage.isEmpty())
tor.setLanguageCode(targetLanguage);
else
@@ -190,8 +190,8 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil
if (tor.locationsType() == Translator::NoLocations) // Could be set from file
theseOptions |= NoLocations;
Translator out = merge(tor, fetchedTor, theseOptions, err);
- if (!codecForTr.isEmpty())
- out.setCodecName(codecForTr);
+ if (setCodec)
+ out.setCodec(fetchedTor.codec());
if ((options & Verbose) && !err.isEmpty()) {
printOut(err);
@@ -374,17 +374,17 @@ static void processProjects(
continue;
}
Translator tor;
- QByteArray codecForTr;
+ bool setCodec = false;
QStringList tmp = visitor.values(QLatin1String("CODEC"))
+ visitor.values(QLatin1String("DEFAULTCODEC"))
+ visitor.values(QLatin1String("CODECFORTR"));
if (!tmp.isEmpty()) {
- codecForTr = tmp.last().toLatin1();
- tor.setCodecName(codecForTr);
+ tor.setCodecName(tmp.last().toLatin1());
+ setCodec = true;
}
processProject(false, pfi, visitor, options, codecForSource,
targetLanguage, sourceLanguage, &tor, fail);
- updateTsFiles(tor, tsFiles, codecForTr, sourceLanguage, targetLanguage, options, fail);
+ updateTsFiles(tor, tsFiles, setCodec, sourceLanguage, targetLanguage, options, fail);
continue;
}
noTrans:
@@ -657,7 +657,7 @@ int main(int argc, char **argv)
cd.m_allCSources = allCSources;
fetchedTor.setCodecName(codecForTr);
processSources(fetchedTor, sourceFiles, cd);
- updateTsFiles(fetchedTor, tsFileNames, codecForTr,
+ updateTsFiles(fetchedTor, tsFileNames, !codecForTr.isEmpty(),
sourceLanguage, targetLanguage, options, &fail);
} else {
if (!sourceFiles.isEmpty() || !includePath.isEmpty()) {
@@ -669,7 +669,7 @@ int main(int argc, char **argv)
fetchedTor.setCodecName(codecForTr);
processProjects(true, true, proFiles, options, QByteArray(),
targetLanguage, sourceLanguage, &fetchedTor, &fail);
- updateTsFiles(fetchedTor, tsFileNames, codecForTr,
+ updateTsFiles(fetchedTor, tsFileNames, !codecForTr.isEmpty(),
sourceLanguage, targetLanguage, options, &fail);
} else {
processProjects(true, false, proFiles, options, QByteArray(),
diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h
index 0fcd598..0b88c07 100644
--- a/tools/linguist/shared/translator.h
+++ b/tools/linguist/shared/translator.h
@@ -153,6 +153,7 @@ public:
void reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose);
void setCodecName(const QByteArray &name);
+ void setCodec(QTextCodec *codec) { m_codec = codec; }
QByteArray codecName() const;
QTextCodec *codec() const { return m_codec; }