本文整理汇总了C++中TranslatorMessage::oldSourceText方法的典型用法代码示例。如果您正苦于以下问题:C++ TranslatorMessage::oldSourceText方法的具体用法?C++ TranslatorMessage::oldSourceText怎么用?C++ TranslatorMessage::oldSourceText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TranslatorMessage
的用法示例。
在下文中一共展示了TranslatorMessage::oldSourceText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeTransUnits
static void writeTransUnits(QTextStream &ts, const TranslatorMessage &msg, const QRegExp &drops, int indent)
{
static int msgid;
QString msgidstr = !msg.id().isEmpty() ? msg.id() : QString::fromAscii("_msg%1").arg(++msgid);
QStringList translns = msg.translations();
QHash<QString, QString>::const_iterator it;
QString pluralStr;
QStringList sources(msg.sourceText());
if ((it = msg.extras().find(QString::fromLatin1("po-msgid_plural"))) != msg.extras().end())
sources.append(*it);
QStringList oldsources;
if (!msg.oldSourceText().isEmpty())
oldsources.append(msg.oldSourceText());
if ((it = msg.extras().find(QString::fromLatin1("po-old_msgid_plural"))) != msg.extras().end()) {
if (oldsources.isEmpty()) {
if (sources.count() == 2)
oldsources.append(QString());
else
pluralStr = QLatin1Char(' ') + QLatin1String(attribPlural) + QLatin1String("=\"yes\"");
}
oldsources.append(*it);
}
QStringList::const_iterator
srcit = sources.begin(), srcend = sources.end(),
oldsrcit = oldsources.begin(), oldsrcend = oldsources.end(),
transit = translns.begin(), transend = translns.end();
int plural = 0;
QString source;
while (srcit != srcend || oldsrcit != oldsrcend || transit != transend) {
QByteArray attribs;
QByteArray state;
if (msg.type() == TranslatorMessage::Obsolete) {
if (!msg.isPlural())
attribs = " translate=\"no\"";
} else if (msg.type() == TranslatorMessage::Finished) {
attribs = " approved=\"yes\"";
} else if (transit != transend && !transit->isEmpty()) {
state = " state=\"needs-review-translation\"";
}
writeIndent(ts, indent);
ts << "<trans-unit id=\"" << msgidstr;
if (msg.isPlural())
ts << "[" << plural++ << "]";
ts << "\"" << attribs << ">\n";
++indent;
writeIndent(ts, indent);
if (srcit != srcend) {
source = *srcit;
++srcit;
} // else just repeat last element
ts << "<source xml:space=\"preserve\">" << protect(source) << "</source>\n";
bool puttrans = false;
QString translation;
if (transit != transend) {
translation = *transit;
translation.replace(QChar(Translator::BinaryVariantSeparator),
QChar(Translator::TextVariantSeparator));
++transit;
puttrans = true;
}
do {
if (oldsrcit != oldsrcend && !oldsrcit->isEmpty()) {
writeIndent(ts, indent);
ts << "<alt-trans>\n";
++indent;
writeIndent(ts, indent);
ts << "<source xml:space=\"preserve\"" << pluralStr << '>' << protect(*oldsrcit) << "</source>\n";
if (!puttrans) {
writeIndent(ts, indent);
ts << "<target restype=\"" << restypeDummy << "\"/>\n";
}
}
if (puttrans) {
writeIndent(ts, indent);
ts << "<target xml:space=\"preserve\"" << state << ">" << protect(translation) << "</target>\n";
}
if (oldsrcit != oldsrcend) {
if (!oldsrcit->isEmpty()) {
--indent;
writeIndent(ts, indent);
ts << "</alt-trans>\n";
}
++oldsrcit;
}
puttrans = false;
} while (srcit == srcend && oldsrcit != oldsrcend);
if (!msg.isPlural()) {
writeLineNumber(ts, msg, indent);
writeComment(ts, msg, drops, indent);
}
--indent;
//.........这里部分代码省略.........