15 m_writer.writeStartDocument();
16 std::for_each(node->m_childs.begin(), node->m_childs.end(), [
this](
const base_node::base_node_ptr node){ node->visit(*this); } );
17 m_writer.writeEndDocument();
25 m_writer.writeDTD(node->
id());
33 m_writer.writeStartElement(node->
name());
35 m_writer.writeCharacters(node->
text());
36 std::for_each(node->m_childs.begin(), node->m_childs.end(), [
this](
const base_node::base_node_ptr node){ node->visit(*this); } );
37 m_writer.writeEndElement();
45 std::for_each(node->m_childs.begin(), node->m_childs.end(), [
this](
const base_node::base_node_ptr node){ node->visit(*this); } );
60 m_state = st_WaitForSource | st_WaitForTranslation;
66 m_state &= ~st_WaitForSource;
68 if(!(m_state & st_WaitForTranslation))
70 m_state |= st_Complete;
81 m_state &= ~st_WaitForTranslation;
83 if(!(m_state & st_WaitForSource))
85 m_state |= st_Complete;
93 if(st_Complete & m_state)
95 bool bSkipProcessing =
false;
97 if(!m_with_unfinished || !m_with_vanished || !m_unfinished_only)
99 QString attr_type = translation->
attributes().value(
"type").toString();
100 if(m_unfinished_only)
102 bSkipProcessing =
"unfinished" != attr_type;
106 bSkipProcessing = (
"unfinished" == attr_type && !m_with_unfinished)
107 || ((
"vanished" == attr_type ||
"obsolete" == attr_type) && !m_with_vanished);
116 if(!translation->
text().isEmpty())
118 text = translation->
text();
122 text = source->
text();
125 hash =
efl_hash(text.toStdWString().c_str());
126 translation->
set_text(QString(
"[[[%1]]]").arg(hash, 8, 16, QChar(
'0')).toUpper());
127 text = QString(
"%1 \"%2\"").arg(translation->
text(), text);
129 text.replace(
"\n",
"\\n");
130 text.replace(
"\r",
"\\r");
131 text.replace(
"\t",
"\\t");
133 m_vqs.insert(map_hashQString::value_type(hash, text));
136 source = translation =
nullptr;
137 m_state = st_WaitForMessage;
140 std::for_each(node->m_childs.begin(), node->m_childs.end(), [
this](
const base_node::base_node_ptr node) { node->visit(*this); });
148 std::for_each(node->m_childs.begin(), node->m_childs.end(), [
this](
const base_node::base_node_ptr node){ node->visit(*this); } );
163 m_state = st_WaitForSource | st_WaitForTranslation;
169 m_state &= ~st_WaitForSource;
171 if(!(m_state & st_WaitForTranslation))
173 m_state |= st_Complete;
182 assert(!translation);
184 m_state &= ~st_WaitForTranslation;
186 if(!(m_state & st_WaitForSource))
188 m_state |= st_Complete;
196 if(st_Complete & m_state)
198 map_QStringQString::const_iterator it = m_strings.find(translation->
text());
200 if(m_strings.end() == it)
202 std::cerr <<
"Unprocessed tags <source>: " << source->
text().toUtf8().constData()
203 <<
" <translation>: " << translation->
text().toUtf8().constData() << std::endl;
207 QString text = it->second;
209 text.replace(
"\\n",
"\n");
210 text.replace(
"\\r",
"\r");
211 text.replace(
"\\t",
"\t");
216 source = translation =
nullptr;
217 m_state = st_WaitForMessage;
220 std::for_each(node->m_childs.begin(), node->m_childs.end(), [
this](
const base_node::base_node_ptr node){ node->visit(*this); } );
228 if(!m_langid.isEmpty())
unsigned long hash_t
type of efl_hash.
hash_t efl_hash(const wchar_t *s)
do some fancy bitwanking on the string. efl_hash
const QString & id() const
void replace_attribute_value(const QString &att_name, const QString &value)
std::shared_ptr< base_node > base_node_ptr
const QString & text() const
const QString & name() const
EElementNodeType element_node_type() const
void set_text(const QString &text)
const QXmlStreamAttributes & attributes() const
void visit(const document_node *node)
visit(const document_node *node). visit
void visit(const document_node *node) const
visit(const document_node *node). visit