static void writeComment(QTextStream &ts, const TranslatorMessage &msg, const QRegExp &drops, int indent) { if (!msg.comment().isEmpty()) { writeIndent(ts, indent); ts << "<context-group><context context-type=\"" << contextMsgctxt << "\">" << protect(msg.comment(), false) << "</context></context-group>\n"; } if (!msg.oldComment().isEmpty()) { writeIndent(ts, indent); ts << "<context-group><context context-type=\"" << contextOldMsgctxt << "\">" << protect(msg.oldComment(), false) << "</context></context-group>\n"; } writeExtras(ts, indent, msg.extras(), drops); if (!msg.extraComment().isEmpty()) { writeIndent(ts, indent); ts << "<note annotates=\"source\" from=\"developer\">" << protect(msg.extraComment()) << "</note>\n"; } if (!msg.translatorComment().isEmpty()) { writeIndent(ts, indent); ts << "<note from=\"translator\">" << protect(msg.translatorComment()) << "</note>\n"; } }
void Translator::extend(const TranslatorMessage &msg, ConversionData &cd) { int index = find(msg); if (index == -1) { append(msg); } else { TranslatorMessage &emsg = m_messages[index]; if (emsg.sourceText().isEmpty()) { delIndex(index); emsg.setSourceText(msg.sourceText()); addIndex(index, msg); } else if (!msg.sourceText().isEmpty() && emsg.sourceText() != msg.sourceText()) { cd.appendError(QString::fromLatin1("Contradicting source strings for message with id '%1'.") .arg(emsg.id())); return; } if (emsg.extras().isEmpty()) { emsg.setExtras(msg.extras()); } else if (!msg.extras().isEmpty() && emsg.extras() != msg.extras()) { cd.appendError(QString::fromLatin1("Contradicting meta data for for %1.") .arg(!emsg.id().isEmpty() ? QString::fromLatin1("message with id '%1'").arg(emsg.id()) : QString::fromLatin1("message '%1'").arg(makeMsgId(msg)))); return; } emsg.addReferenceUniq(msg.fileName(), msg.lineNumber()); if (!msg.extraComment().isEmpty()) { QString cmt = emsg.extraComment(); if (!cmt.isEmpty()) { QStringList cmts = cmt.split(QLatin1String("\n----------\n")); if (!cmts.contains(msg.extraComment())) { cmts.append(msg.extraComment()); cmt = cmts.join(QLatin1String("\n----------\n")); } } else { cmt = msg.extraComment(); } emsg.setExtraComment(cmt); } } }
void Translator::extend(const TranslatorMessage &msg) { int index = find(msg); if (index == -1) { append(msg); } else { TranslatorMessage &emsg = m_messages[index]; emsg.addReferenceUniq(msg.fileName(), msg.lineNumber()); if (!msg.extraComment().isEmpty()) { QString cmt = emsg.extraComment(); if (!cmt.isEmpty()) cmt.append(QLatin1String("\n----------\n")); cmt.append(msg.extraComment()); emsg.setExtraComment(cmt); } if (msg.isUtf8() != emsg.isUtf8()) { emsg.setUtf8(true); emsg.setNonUtf8(true); } } }