summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-03-05 18:05:49 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-12 22:07:28 +0100
commitcb1f26633db3e33a263555a8758f4e8a591aeab6 (patch)
tree40de034c00ec3ec057d28b6f0f2a10c64b99acdc
parent3028d13439f241a9b05a7de3b32fd6c2ee16cb8d (diff)
downloadqttools-cb1f26633db3e33a263555a8758f4e8a591aeab6.tar.gz
purge TS 1.1 support
at the time of release it will be almost five years since we introduced TS 2.0 and stopped writing 1.1 by default, so there shouldn't be much of a need to write such files any more - and this commit doesn't even remove 1.1 reading capability (because it comes for free so far). Change-Id: Ie54fe31f83733ef944306c01301c0ec0e9bcb8bf Reviewed-by: hjk <hjk121@nokiamail.com>
-rw-r--r--src/linguist/shared/ts.cpp117
-rw-r--r--tests/auto/linguist/lconvert/data/test11.ts32
-rw-r--r--tests/auto/linguist/lconvert/tst_lconvert.cpp7
-rw-r--r--tests/auto/linguist/lrelease/testdata/mixedcodecs-ts11.ts18
-rw-r--r--tests/auto/linguist/lrelease/tst_lrelease.cpp8
5 files changed, 16 insertions, 166 deletions
diff --git a/src/linguist/shared/ts.cpp b/src/linguist/shared/ts.cpp
index f7dab9c55..74ad45e9a 100644
--- a/src/linguist/shared/ts.cpp
+++ b/src/linguist/shared/ts.cpp
@@ -60,10 +60,6 @@ QT_BEGIN_NAMESPACE
* in that encoding or as UTF-8 to trUtf8() if it is flagged as such.
* For ts 2.0, the file content is always uniformly in UTF-8. The file stores
* the codecForTr default and marks deviating messages accordingly.
- * For ts 1.1, the file content is in mixed encoding. Each message is encoded
- * the way it will be passed to tr() (with 8-bit characters encoded as numeric
- * entities) or trUtf8(). The file stores the encoding and codecForTr in one
- * attribute, for both the default and each deviating message.
*/
@@ -504,33 +500,6 @@ static QString protect(const QString &str)
return result;
}
-static QString evilBytes(const QString& str,
- bool isUtf8, int format, const QByteArray &codecName)
-{
- //qDebug() << "EVIL: " << str << isUtf8 << format << codecName;
- if (isUtf8)
- return protect(str);
- if (format == 20)
- return protect(str);
- if (codecName == "UTF-8")
- return protect(str);
- QTextCodec *codec = QTextCodec::codecForName(codecName);
- if (!codec)
- return protect(str);
- QString t = QString::fromLatin1(codec->fromUnicode(protect(str)).data());
- int len = (int) t.length();
- QString result;
- // FIXME: Factor is sensible only for latin scripts, probably.
- result.reserve(t.length() * 2);
- for (int k = 0; k < len; k++) {
- if (t[k].unicode() >= 0x7f)
- result += numericEntity(t[k].unicode());
- else
- result += t[k];
- }
- return result;
-}
-
static void writeExtras(QTextStream &t, const char *indent,
const TranslatorMessage::ExtraData &extras, QRegExp drops)
{
@@ -570,31 +539,25 @@ static void writeVariants(QTextStream &t, const char *indent, const QString &inp
}
}
-bool saveTS(const Translator &translator, QIODevice &dev, ConversionData &cd, int format)
+bool saveTS(const Translator &translator, QIODevice &dev, ConversionData &cd)
{
bool result = true;
QTextStream t(&dev);
t.setCodec(QTextCodec::codecForName("UTF-8"));
bool trIsUtf8 = (translator.codecName() == "UTF-8");
//qDebug() << translator.codecName();
- bool fileIsUtf8 = (format == 20 || trIsUtf8);
// The xml prolog allows processors to easily detect the correct encoding
t << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE TS>\n";
- if (format == 11)
- t << "<TS version=\"1.1\"";
- else
- t << "<TS version=\"2.0\"";
+ t << "<TS version=\"2.0\"";
QString languageCode = translator.languageCode();
if (!languageCode.isEmpty() && languageCode != QLatin1String("C"))
t << " language=\"" << languageCode << "\"";
- if (format == 20) {
- languageCode = translator.sourceLanguageCode();
- if (!languageCode.isEmpty() && languageCode != QLatin1String("C"))
- t << " sourcelanguage=\"" << languageCode << "\"";
- }
+ languageCode = translator.sourceLanguageCode();
+ if (!languageCode.isEmpty() && languageCode != QLatin1String("C"))
+ t << " sourcelanguage=\"" << languageCode << "\"";
t << ">\n";
QByteArray codecName = translator.codecName();
@@ -611,8 +574,7 @@ bool saveTS(const Translator &translator, QIODevice &dev, ConversionData &cd, in
QRegExp drops(cd.dropTags().join(QLatin1String("|")));
- if (format == 20)
- writeExtras(t, " ", translator.extras(), drops);
+ writeExtras(t, " ", translator.extras(), drops);
QHash<QString, QList<TranslatorMessage> > messageOrder;
QList<QString> contextOrder;
@@ -632,34 +594,23 @@ bool saveTS(const Translator &translator, QIODevice &dev, ConversionData &cd, in
QHash<QString, int> currentLine;
QString currentFile;
foreach (const QString &context, contextOrder) {
- const TranslatorMessage &firstMsg = messageOrder[context].first();
- t << "<context" << ((!fileIsUtf8 && firstMsg.isUtf8()) ? " encoding=\"UTF-8\"" : "") << ">\n";
-
- t << " <name>"
- << evilBytes(context, firstMsg.isUtf8() || fileIsUtf8, format, codecName)
+ t << "<context>\n"
+ " <name>"
+ << protect(context)
<< "</name>\n";
foreach (const TranslatorMessage &msg, messageOrder[context]) {
//msg.dump();
- bool isUtf8 = msg.isUtf8();
- bool second = false;
- forever {
-
t << " <message";
if (!msg.id().isEmpty())
t << " id=\"" << msg.id() << "\"";
if (!trIsUtf8) {
- if (format == 11) {
- if (isUtf8)
- t << " encoding=\"UTF-8\"";
- } else {
if (msg.isUtf8()) {
if (msg.isNonUtf8())
t << " utf8=\"both\"";
else
t << " utf8=\"true\"";
}
- }
}
if (msg.isPlural())
t << " numerus=\"yes\"";
@@ -703,20 +654,18 @@ bool saveTS(const Translator &translator, QIODevice &dev, ConversionData &cd, in
}
t << " <source>"
- << evilBytes(msg.sourceText(), isUtf8, format, codecName)
+ << protect(msg.sourceText())
<< "</source>\n";
- if (format != 11 && !msg.oldSourceText().isEmpty())
+ if (!msg.oldSourceText().isEmpty())
t << " <oldsource>" << protect(msg.oldSourceText()) << "</oldsource>\n";
if (!msg.comment().isEmpty()) {
t << " <comment>"
- << evilBytes(msg.comment(), isUtf8, format, codecName)
+ << protect(msg.comment())
<< "</comment>\n";
}
- if (format != 11) {
-
if (!msg.oldComment().isEmpty())
t << " <oldcomment>" << protect(msg.oldComment()) << "</oldcomment>\n";
@@ -728,8 +677,6 @@ bool saveTS(const Translator &translator, QIODevice &dev, ConversionData &cd, in
t << " <translatorcomment>" << protect(msg.translatorComment())
<< "</translatorcomment>\n";
- }
-
t << " <translation";
if (msg.type() == TranslatorMessage::Unfinished)
t << " type=\"unfinished\"";
@@ -749,18 +696,11 @@ bool saveTS(const Translator &translator, QIODevice &dev, ConversionData &cd, in
}
t << "</translation>\n";
- if (format != 11)
- writeExtras(t, " ", msg.extras(), drops);
+ writeExtras(t, " ", msg.extras(), drops);
if (!msg.userData().isEmpty())
t << " <userdata>" << msg.userData() << "</userdata>\n";
t << " </message>\n";
-
- if (format != 11 || second || !msg.isUtf8() || !msg.isNonUtf8())
- break;
- isUtf8 = false;
- second = true;
- }
}
t << "</context>\n";
}
@@ -775,43 +715,16 @@ bool loadTS(Translator &translator, QIODevice &dev, ConversionData &cd)
return reader.read(translator);
}
-bool saveTS11(const Translator &translator, QIODevice &dev, ConversionData &cd)
-{
- return saveTS(translator, dev, cd, 11);
-}
-
-bool saveTS20(const Translator &translator, QIODevice &dev, ConversionData &cd)
-{
- return saveTS(translator, dev, cd, 20);
-}
-
int initTS()
{
Translator::FileFormat format;
- format.extension = QLatin1String("ts11");
- format.fileType = Translator::FileFormat::TranslationSource;
- format.priority = -1;
- format.description = QObject::tr("Qt translation sources (format 1.1)");
- format.loader = &loadTS;
- format.saver = &saveTS11;
- Translator::registerFileFormat(format);
-
- format.extension = QLatin1String("ts20");
- format.fileType = Translator::FileFormat::TranslationSource;
- format.priority = -1;
- format.description = QObject::tr("Qt translation sources (format 2.0)");
- format.loader = &loadTS;
- format.saver = &saveTS20;
- Translator::registerFileFormat(format);
-
- // "ts" is always the latest. right now it's ts20.
format.extension = QLatin1String("ts");
format.fileType = Translator::FileFormat::TranslationSource;
format.priority = 0;
- format.description = QObject::tr("Qt translation sources (latest format)");
+ format.description = QObject::tr("Qt translation sources");
format.loader = &loadTS;
- format.saver = &saveTS20;
+ format.saver = &saveTS;
Translator::registerFileFormat(format);
return 1;
diff --git a/tests/auto/linguist/lconvert/data/test11.ts b/tests/auto/linguist/lconvert/data/test11.ts
deleted file mode 100644
index aeb46af9f..000000000
--- a/tests/auto/linguist/lconvert/data/test11.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="1.1" language="de_DE">
-<context>
- <name>FindDialog</name>
- <message>
- <location filename="finddialog.cpp" line="57"/>
- <source>Enter the text you want to find.</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="finddialog.cpp" line="107"/>
- <source>Search reached end of the document</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="finddialog.cpp" line="109"/>
- <source>Search reached start of the document</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="finddialog.cpp" line="111"/>
- <source>Text not found</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="finddialog.cpp" line="122"/>
- <source>Should be obsolete</source>
- <translation type="unfinished">SHOULD BE OBSOLETE</translation>
- </message>
-</context>
-</TS>
diff --git a/tests/auto/linguist/lconvert/tst_lconvert.cpp b/tests/auto/linguist/lconvert/tst_lconvert.cpp
index 83f58539f..0f4dfcdad 100644
--- a/tests/auto/linguist/lconvert/tst_lconvert.cpp
+++ b/tests/auto/linguist/lconvert/tst_lconvert.cpp
@@ -285,9 +285,7 @@ void tst_lconvert::roundtrips_data()
QStringList poTsPo; poTsPo << "po" << "ts" << "po";
QStringList poXlfPo; poXlfPo << "po" << "xlf" << "po";
- QStringList tsTs11Ts; tsTs11Ts << "ts" << "ts11" << "ts";
QStringList tsPoTs; tsPoTs << "ts" << "po" << "ts";
- QStringList ts11PoTs11; ts11PoTs11 << "ts11" << "po" << "ts11";
QStringList tsXlfTs; tsXlfTs << "ts" << "xlf" << "ts";
QStringList tsQmTs; tsQmTs << "ts" << "qm" << "ts";
@@ -301,7 +299,6 @@ void tst_lconvert::roundtrips_data()
QTest::newRow("po-ts-po (developer comment)") << "test-developer-comment.po" << poTsPo << noArgs;
QTest::newRow("po-xliff-po (developer comment)") << "test-developer-comment.po" << poXlfPo << noArgs;
- QTest::newRow("ts11-po-ts11") << "test11.ts" << ts11PoTs11 << filterPoArgs;
QTest::newRow("ts20-po-ts20") << "test20.ts" << tsPoTs << filterPoArgs;
QTest::newRow("po-ts-po (de)") << "test1-de.po" << poTsPo << noArgs;
QTest::newRow("po-ts-po (cn)") << "test1-cn.po" << poTsPo << noArgs;
@@ -319,10 +316,6 @@ void tst_lconvert::roundtrips_data()
QTest::newRow("po-ts-po (references)") << "test-refs.po" << poTsPo << noArgs;
- QTest::newRow("ts20-ts11-ts20 (utf8)") << "codec-utf8.ts" << tsTs11Ts << noArgs;
- QTest::newRow("ts20-ts11-ts20 (cp1252)") << "codec-cp1252.ts" << tsTs11Ts << noArgs;
- QTest::newRow("ts20-ts11-ts20 (dual-encoding)") << "dual-encoding.ts" << tsTs11Ts << noArgs;
-
QTest::newRow("ts-qm-ts (dual-encoding)") << "dual-encoding.ts" << tsQmTs << noArgs;
QTest::newRow("ts-qm-ts (plurals-de)") << "plurals-de.ts" << tsQmTs << outDeArgs;
QTest::newRow("ts-qm-ts (plurals-cn)") << "plurals-cn.ts" << tsQmTs << outCnArgs;
diff --git a/tests/auto/linguist/lrelease/testdata/mixedcodecs-ts11.ts b/tests/auto/linguist/lrelease/testdata/mixedcodecs-ts11.ts
deleted file mode 100644
index 991f35432..000000000
--- a/tests/auto/linguist/lrelease/testdata/mixedcodecs-ts11.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="1.1">
-<defaultcodec>windows-1252</defaultcodec>
-<context>
- <name>FooBar</name>
- <message>
- <location filename="main.cpp" line="11"/>
- <source>this contains an umlaut &#xfc; &amp;uuml;</source>
- <translation>random stuff with umlaut</translation>
- </message>
- <message encoding="UTF-8">
- <location filename="main.cpp" line="13"/>
- <source>umlaut ΓΌ &amp;uuml; in utf8</source>
- <translation>more random stuff with umlaut</translation>
- </message>
-</context>
-</TS>
diff --git a/tests/auto/linguist/lrelease/tst_lrelease.cpp b/tests/auto/linguist/lrelease/tst_lrelease.cpp
index fc9f96d5f..c3593da68 100644
--- a/tests/auto/linguist/lrelease/tst_lrelease.cpp
+++ b/tests/auto/linguist/lrelease/tst_lrelease.cpp
@@ -173,16 +173,10 @@ void tst_lrelease::translate()
void tst_lrelease::mixedcodecs()
{
- QVERIFY(!QProcess::execute(binDir + "/lrelease " + dataDir + "mixedcodecs-ts11.ts"));
QVERIFY(!QProcess::execute(binDir + "/lrelease " + dataDir + "mixedcodecs-ts20.ts"));
-#ifdef Q_OS_WIN
- QVERIFY(!QProcess::execute("fc /b testdata\\mixedcodecs-ts11.qm testdata\\mixedcodecs-ts20.qm"));
-#else
- QVERIFY(!QProcess::execute("cmp " + dataDir + "mixedcodecs-ts11.qm " + dataDir + "mixedcodecs-ts20.qm"));
-#endif
QTranslator translator;
- QVERIFY(translator.load(dataDir + "mixedcodecs-ts11.qm"));
+ QVERIFY(translator.load(dataDir + "mixedcodecs-ts20.qm"));
qApp->installTranslator(&translator);
QCOMPARE(QCoreApplication::translate("FooBar", "this contains an umlaut \xfc &uuml;"),