本文整理汇总了C++中Translator::extras方法的典型用法代码示例。如果您正苦于以下问题:C++ Translator::extras方法的具体用法?C++ Translator::extras怎么用?C++ Translator::extras使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translator
的用法示例。
在下文中一共展示了Translator::extras方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveXLIFF
bool saveXLIFF(const Translator &translator, QIODevice &dev, ConversionData &cd)
{
bool ok = true;
int indent = 0;
QTextStream ts(&dev);
ts.setCodec(QTextCodec::codecForName("UTF-8"));
QStringList dtgs = cd.dropTags();
dtgs << QLatin1String("po-(old_)?msgid_plural");
QRegExp drops(dtgs.join(QLatin1String("|")));
QHash<QString, QHash<QString, QList<TranslatorMessage> > > messageOrder;
QHash<QString, QList<QString> > contextOrder;
QList<QString> fileOrder;
foreach (const TranslatorMessage &msg, translator.messages()) {
QString fn = msg.fileName();
if (fn.isEmpty() && msg.type() == TranslatorMessage::Obsolete)
fn = QLatin1String(MAGIC_OBSOLETE_REFERENCE);
QHash<QString, QList<TranslatorMessage> > &file = messageOrder[fn];
if (file.isEmpty())
fileOrder.append(fn);
QList<TranslatorMessage> &context = file[msg.context()];
if (context.isEmpty())
contextOrder[fn].append(msg.context());
context.append(msg);
}
ts.setFieldAlignment(QTextStream::AlignRight);
ts << "<?xml version=\"1.0\"";
ts << " encoding=\"utf-8\"?>\n";
ts << "<xliff version=\"1.2\" xmlns=\"" << XLIFF12namespaceURI
<< "\" xmlns:trolltech=\"" << TrollTsNamespaceURI << "\">\n";
++indent;
writeExtras(ts, indent, translator.extras(), drops);
QString sourceLanguageCode = translator.sourceLanguageCode();
if (sourceLanguageCode.isEmpty() || sourceLanguageCode == QLatin1String("C"))
sourceLanguageCode = QLatin1String("en");
else
sourceLanguageCode.replace(QLatin1Char('_'), QLatin1Char('-'));
QString languageCode = translator.languageCode();
languageCode.replace(QLatin1Char('_'), QLatin1Char('-'));
foreach (const QString &fn, fileOrder) {
writeIndent(ts, indent);
ts << "<file original=\"" << fn << "\""
<< " datatype=\"" << dataType(messageOrder[fn].begin()->first()) << "\""
<< " source-language=\"" << sourceLanguageCode.toLatin1() << "\""
<< " target-language=\"" << languageCode.toLatin1() << "\""
<< "><body>\n";
++indent;
foreach (const QString &ctx, contextOrder[fn]) {
if (!ctx.isEmpty()) {
writeIndent(ts, indent);
ts << "<group restype=\"" << restypeContext << "\""
<< " resname=\"" << protect(ctx) << "\">\n";
++indent;
}
foreach (const TranslatorMessage &msg, messageOrder[fn][ctx])
writeMessage(ts, msg, drops, indent);
if (!ctx.isEmpty()) {
--indent;
writeIndent(ts, indent);
ts << "</group>\n";
}
}
--indent;
writeIndent(ts, indent);
ts << "</body></file>\n";
}