using and exporting source and explanation

This commit is contained in:
Ozbolt Menegatti 2019-11-15 22:22:03 +01:00
parent c5c4d9b10a
commit 78a80c03a7
2 changed files with 9 additions and 0 deletions

View File

@ -103,8 +103,13 @@ def export_translation(doc, translation):
actual_t = doc.createElement("translation") actual_t = doc.createElement("translation")
actual_t.textContent = translation.translation actual_t.textContent = translation.translation
actual_t.setAttribute("source", translation.source)
translation_xml.appendChild(actual_t) translation_xml.appendChild(actual_t)
explanation = doc.createElement("explanation")
explanation.textContent = translation.explanation
translation_xml.appendChild(explanation)
tags = doc.createElement("tagsContainer") tags = doc.createElement("tagsContainer")
translation_xml.appendChild(tags) translation_xml.appendChild(tags)

View File

@ -10,6 +10,10 @@ class Translation:
def __init__(self, translation_xml): def __init__(self, translation_xml):
translation = translation_xml.querySelector("translation") translation = translation_xml.querySelector("translation")
self.translation = translation.textContent if translation else "" self.translation = translation.textContent if translation else ""
self.source = translation.getAttribute("source") or ""
explanation = translation_xml.querySelector("explanation")
self.explanation = explanation.textContent if explanation else ""
self.tags = {} self.tags = {}
for tag_xml in translation_xml.querySelectorAll("tagsContainer tag"): for tag_xml in translation_xml.querySelectorAll("tagsContainer tag"):