From 19b880ad763ddad0473d402b9a2c9e39514c5b89 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 12 Aug 2016 17:37:09 +0300 Subject: [PATCH] New test localization (checking html tags mismatch). --HG-- branch : develop --- share/translations/valentina_it_IT.ts | 2 +- share/translations/valentina_ru_RU.ts | 14 +-- .../TranslationsTest/tst_tstranslation.cpp | 92 +++++++++++++++++++ src/test/TranslationsTest/tst_tstranslation.h | 2 + 4 files changed, 102 insertions(+), 8 deletions(-) diff --git a/share/translations/valentina_it_IT.ts b/share/translations/valentina_it_IT.ts index 8634352bb..3ba2adf9f 100644 --- a/share/translations/valentina_it_IT.ts +++ b/share/translations/valentina_it_IT.ts @@ -5541,7 +5541,7 @@ Vuoi salvare i cambiamenti? <html><head/><body><p>Mode for working with pattern pieces. These pattern pieces are base for going to the next stage &quot;Details mode&quot;. Before you will be able to enable the &quot;Details mode&quot; need create at least one detail.</p></body></html> - <html> <head /> <body> <p> Modalità per lavorare con i pezzi del modello. Questi pezzi del modello sono la base per andare alla fase successiva &quot; dettagli mode&quot;. Prima si sarà in grado di abilitare i &quot; Dettagli mode&quot; devono creare almeno un dettaglio. </ p> </ body> </ html> + <html> <head/> <body> <p> Modalità per lavorare con i pezzi del modello. Questi pezzi del modello sono la base per andare alla fase successiva &quot; dettagli mode&quot;. Prima si sarà in grado di abilitare i &quot; Dettagli mode&quot; devono creare almeno un dettaglio. </p> </body> </html> <html><head/><body><p>Mode for working with details. Before you will be able to enable the &quot;Details mode&quot; need create at least one detail on the stage &quot;Draw mode&quot;. Details created on this stage will be used for creating a layout. </p></body></html> diff --git a/share/translations/valentina_ru_RU.ts b/share/translations/valentina_ru_RU.ts index b17e246aa..11083e23b 100644 --- a/share/translations/valentina_ru_RU.ts +++ b/share/translations/valentina_ru_RU.ts @@ -411,7 +411,7 @@ <html><head/><body><p>Show full calculation in message box</p></body></html> - <html><head/><body><р>Показать полный расчет в окне сообщения</p></body</html> + <html><head/><body><p>Показать полный расчет в окне сообщения</p></body></html> Point label @@ -929,7 +929,7 @@ <html><head/><body><p>Show full calculation in message box</p></body></html> - <html><head/><body><р>Показать полный расчет в окне сообщения</p></body</html> + <html><head/><body><p>Показать полный расчет в окне сообщения</p></body></html> Axis point @@ -2483,7 +2483,7 @@ Apply settings anyway? <html><head/><body><p>Show full calculation in message box</p></body></html> - <html><head/><body><р>Показать полный расчет в окне сообщения</p></body</html> + <html><head/><body><p>Показать полный расчет в окне сообщения</p></body></html> Axis point @@ -3268,7 +3268,7 @@ Apply settings anyway? <html><head/><body><p>Show full calculation in message box</p></body></html> - <html><head/><body><р>Показать полный расчёт в окне сообщения</p></body</html> + <html><head/><body><p>Показать полный расчёт в окне сообщения</p></body></html> Point label @@ -3714,7 +3714,7 @@ Apply settings anyway? <html><head/><body><p>Show full calculation in message box</p></body></html> - + <html><head/><body><p>Показать полный расчет в окне сообщения</p></body></html> Origin Point: @@ -4081,7 +4081,7 @@ Apply settings anyway? <html><head/><body><p>Show full calculation in message box</p></body></html> - + <html><head/><body><p>Показать полный расчет в окне сообщения</p></body></html> Edit first control point angle @@ -4200,7 +4200,7 @@ Apply settings anyway? <html><head/><body><p>Show full calculation in message box</p></body></html> - + <html><head/><body><p>Показать полный расчет в окне сообщения</p></body></html> Edit first control point angle diff --git a/src/test/TranslationsTest/tst_tstranslation.cpp b/src/test/TranslationsTest/tst_tstranslation.cpp index 7a7505fe5..584ba82d0 100644 --- a/src/test/TranslationsTest/tst_tstranslation.cpp +++ b/src/test/TranslationsTest/tst_tstranslation.cpp @@ -392,6 +392,98 @@ void TST_TSTranslation::TestPunctuation() } } +//--------------------------------------------------------------------------------------------------------------------- +void TST_TSTranslation::TestHTMLTags_data() +{ + const QStringList locales = SupportedLocales(); + + { + QDir dir(TS_DIR); + const QStringList fileNames = dir.entryList(QStringList("valentina*.ts")); + QVERIFY2(locales.size() == fileNames.size()-1, "Unexpected count of files."); + } + + QTest::addColumn("source"); + QTest::addColumn("translation"); + + for(int j = 0; j < locales.size(); ++j) + { + const QString filename = QString("valentina_%1.ts").arg(locales.at(j)); + + const QDomNodeList messages = LoadTSFile(filename); + if (messages.isEmpty()) + { + QFAIL("Can't begin test."); + } + + for (qint32 i = 0, num = messages.size(); i < num; ++i) + { + const QDomElement message = messages.at(i).toElement(); + if (message.isNull() == false) + { + const QString source = message.firstChildElement(TagSource).text(); + if (source.isEmpty()) + { + continue; + } + + const QDomElement translationTag = message.firstChildElement(TagTranslation); + if (translationTag.hasAttribute(AttrType)) + { + const QString attrVal = translationTag.attribute(AttrType); + if (attrVal == AttrValVanished || attrVal == AttrValUnfinished || attrVal == AttrValObsolete) + { + continue; + } + } + const QString translation = translationTag.text(); + if (translation.isEmpty()) + { + continue; + } + + const QString message = QString("File '%1'.").arg(filename); + QTest::newRow(qUtf8Printable(message)) << source << translation; + } + else + { + const QString message = QString("File '%2'. Message %1 is null.").arg(i).arg(filename); + QFAIL(qUtf8Printable(message)); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_TSTranslation::TestHTMLTags() +{ + QFETCH(QString, source); + QFETCH(QString, translation); + + static const QStringList tags = QStringList() << QLatin1String("p") + << QLatin1String("html") + << QLatin1String("body"); + static const QString pattern("{1}.*>"); + for (int i=0; i < tags.size(); ++i) + { + const QRegularExpression openRegex(QLatin1String("<") + tags.at(i) + pattern, + QRegularExpression::DotMatchesEverythingOption); + if (source.contains(openRegex)) + { + const int countOpenTag = source.count(openRegex); + const QRegularExpression closeRegex(QLatin1String("'. ").arg(tags.at(i)) + + QString("Original name:'%1'").arg(source) + QString(", translated name:'%1'").arg(translation); + QFAIL(qUtf8Printable(message)); + } + } + } +} + //--------------------------------------------------------------------------------------------------------------------- QDomNodeList TST_TSTranslation::LoadTSFile(const QString &filename) { diff --git a/src/test/TranslationsTest/tst_tstranslation.h b/src/test/TranslationsTest/tst_tstranslation.h index 22cee120f..aa68586cd 100644 --- a/src/test/TranslationsTest/tst_tstranslation.h +++ b/src/test/TranslationsTest/tst_tstranslation.h @@ -49,6 +49,8 @@ private slots: void CheckPlaceMarkerExist(); void TestPunctuation_data(); void TestPunctuation(); + void TestHTMLTags_data(); + void TestHTMLTags(); private: Q_DISABLE_COPY(TST_TSTranslation)