Skip to content

Commit

Permalink
XLIFF 1.2: respect order of <seg-source> too
Browse files Browse the repository at this point in the history
When adding a new <target> node, make sure that it follows the spec,
which says <source> is followed by <seg-source> is followed by <target>.

Previously, <target> was inserted right after <source>.
  • Loading branch information
vslavik committed Sep 26, 2024
1 parent 177ed21 commit b0b17b4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/catalog_xliff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,13 @@ class XLIFF12CatalogItem : public XLIFFCatalogItem
if (!target)
{
auto ws_after = m_node.first_child();
auto source = m_node.child("source");
target = m_node.insert_child_after("target", source);
auto prev = m_node.child("seg-source");
if (!prev)
prev = m_node.child("source");
target = m_node.insert_child_after("target", prev);
// indent the <target> tag in the same way <source> is indented under its parent:
if (ws_after.type() == node_pcdata)
m_node.insert_child_after(node_pcdata, source).text() = ws_after.text().get();
m_node.insert_child_after(node_pcdata, prev).text() = ws_after.text().get();
}

auto trans = GetTranslation();
Expand Down

0 comments on commit b0b17b4

Please sign in to comment.