39 m_currentField = NoField;
42 if (isStartElement()) {
43 if (name() == QLatin1String(
"source")) {
44 m_currentField = SourceField;
45 }
else if (name() == QLatin1String(
"target")) {
46 m_currentField = TargetField;
47 }
else if (name() == QLatin1String(
"definition")) {
48 m_currentField = DefinitionField;
50 m_currentField = NoField;
51 if (name() == QLatin1String(
"QPH")) {
52 QXmlStreamAttributes atts = attributes();
53 translator.setLanguageCode(atts.value(QLatin1String(
"language")).toString());
54 translator.setSourceLanguageCode(atts.value(QLatin1String(
"sourcelanguage")).toString());
57 }
else if (isWhiteSpace()) {
59 }
else if (isCharacters()) {
60 if (m_currentField == SourceField)
61 m_currentSource += text();
62 else if (m_currentField == TargetField)
63 m_currentTarget += text();
64 else if (m_currentField == DefinitionField)
65 m_currentDefinition += text();
66 }
else if (isEndElement() && name() == QLatin1String(
"phrase")) {
67 m_currentTarget.replace(Translator::TextVariantSeparator, Translator::BinaryVariantSeparator);
69 msg.setSourceText(m_currentSource);
70 msg.setTranslation(m_currentTarget);
71 msg.setComment(m_currentDefinition);
73 m_currentSource.clear();
74 m_currentTarget.clear();
75 m_currentDefinition.clear();
123 t <<
"<!DOCTYPE QPH>\n<QPH";
124 QString languageCode = translator.languageCode();
125 if (!languageCode.isEmpty() && languageCode != QLatin1String(
"C"))
126 t <<
" language=\"" << languageCode <<
"\"";
127 languageCode = translator.sourceLanguageCode();
128 if (!languageCode.isEmpty() && languageCode != QLatin1String(
"C"))
129 t <<
" sourcelanguage=\"" << languageCode <<
"\"";
131 for (
const TranslatorMessage &msg : translator.messages()) {
133 t <<
" <source>" << qphProtect(msg.sourceText()) <<
"</source>\n";
134 QString str = msg.translations().join(QLatin1Char(
'@'));
135 str.replace(QChar(Translator::BinaryVariantSeparator),
136 QChar(Translator::TextVariantSeparator));
137 t <<
" <target>" << qphProtect(str)
139 if (!msg.comment().isEmpty())
140 t <<
" <definition>" << qphProtect(msg.comment()) <<
"</definition>\n";