Check embedded translations using each catalog context
This commit is contained in:
1 parent
780e7220c3
commit
ffcb02354f
1 file changed
+5
-2
@@ -185,7 +185,7 @@ private slots:
|
||||
QFile file(QStringLiteral(GUI_TS_DIR) + "/chatgui_" + language + ".ts");
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
QXmlStreamReader xml(&file);
|
||||
QString source;
|
||||
QString source, context;
|
||||
int count = 0;
|
||||
const QRegularExpression placeholders("%(?:L?[1-9][0-9]?|n)");
|
||||
auto parameters = [&](const QString& text) {
|
||||
@@ -198,18 +198,21 @@ private slots:
|
||||
while (!xml.atEnd()) {
|
||||
xml.readNext();
|
||||
if (!xml.isStartElement()) continue;
|
||||
if (xml.name() == QLatin1String("name")) context = xml.readElementText();
|
||||
if (xml.name() == QLatin1String("source")) source = xml.readElementText();
|
||||
if (xml.name() != QLatin1String("translation")) continue;
|
||||
QVERIFY(!xml.attributes().hasAttribute("type"));
|
||||
const QString translation = xml.readElementText();
|
||||
QVERIFY2(!translation.isEmpty(), qPrintable(source));
|
||||
QCOMPARE(parameters(translation), parameters(source));
|
||||
QCOMPARE(QCoreApplication::translate("ChatGui", source.toUtf8().constData()), translation);
|
||||
QVERIFY(!context.isEmpty());
|
||||
QCOMPARE(QCoreApplication::translate(context.toUtf8().constData(), source.toUtf8().constData()), translation);
|
||||
if (language == "en") QCOMPARE(translation, source);
|
||||
count++;
|
||||
}
|
||||
QVERIFY2(!xml.hasError(), qPrintable(xml.errorString()));
|
||||
QVERIFY(count > 0);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "embedded catalog verified language=%s messages=%d", qPrintable(language), count);
|
||||
qApp->removeTranslator(&translator);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user