QXmlStream: resolve puzzle in translatable strings

Task-number: QTBUG-60159
Change-Id: I4cc83f50d38205eb2996d4122d487d07cc3d8677
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: GunChleoc <fios@foramnagaidhlig.net>
bb10
Oswald Buddenhagen 2017-04-13 15:31:32 +02:00
parent 710875efde
commit c2af0f60d4
1 changed files with 15 additions and 22 deletions

View File

@ -1886,32 +1886,25 @@ void QXmlStreamReaderPrivate::parseError()
}
}
error_message.clear ();
if (nexpected && nexpected < nmax) {
bool first = true;
for (int s = 0; s < nexpected; ++s) {
if (first)
error_message += QXmlStream::tr ("Expected ");
else if (s == nexpected - 1)
error_message += QLatin1String (nexpected > 2 ? ", or " : " or ");
else
error_message += QLatin1String (", ");
first = false;
error_message += QLatin1String("\'");
error_message += QLatin1String (spell [expected[s]]);
error_message += QLatin1String("\'");
//: '<first option>'
QString exp_str = QXmlStream::tr("'%1'", "expected").arg(QLatin1String(spell[expected[0]]));
if (nexpected == 2) {
//: <first option>, '<second option>'
exp_str = QXmlStream::tr("%1 or '%2'", "expected").arg(exp_str, QLatin1String(spell[expected[1]]));
} else if (nexpected > 2) {
int s = 1;
for (; s < nexpected - 1; ++s) {
//: <options so far>, '<next option>'
exp_str = QXmlStream::tr("%1, '%2'", "expected").arg(exp_str, QLatin1String(spell[expected[s]]));
}
//: <options so far>, or '<final option>'
exp_str = QXmlStream::tr("%1, or '%2'", "expected").arg(exp_str, QLatin1String(spell[expected[s]]));
}
error_message += QXmlStream::tr(", but got \'");
error_message += QLatin1String(spell [token]);
error_message += QLatin1String("\'");
error_message = QXmlStream::tr("Expected %1, but got '%2'.").arg(exp_str, QLatin1String(spell[token]));
} else {
error_message += QXmlStream::tr("Unexpected \'");
error_message += QLatin1String(spell [token]);
error_message += QLatin1String("\'");
error_message = QXmlStream::tr("Unexpected '%1'.").arg(QLatin1String(spell[token]));
}
error_message += QLatin1Char('.');
raiseWellFormedError(error_message);
}