parent
8820b5700f
commit
17153d78b6
@ -1,25 +1,21 @@
|
|||||||
from model.tags import TAGS
|
from model.tags import import_label_list
|
||||||
from model.editable import Editable
|
from model.editable import Editable
|
||||||
|
|
||||||
|
|
||||||
class Translation(Editable):
|
class Translation(Editable):
|
||||||
def __init__(self, translation_xml):
|
def __init__(self, translation_xml):
|
||||||
translation = translation_xml.querySelector("translation")
|
translation = translation_xml.querySelector("translation")
|
||||||
self.translation = translation.textContent
|
|
||||||
self.source = translation.getAttribute("source") if translation.hasAttribute("source") else ""
|
if translation:
|
||||||
self.targetLang = translation.getAttribute("targetLang") if translation.hasAttribute("targetLang") else ""
|
self.translation = translation.textContent
|
||||||
|
self.source = translation.getAttribute("source") if translation.hasAttribute("source") else ""
|
||||||
|
self.targetLang = translation.getAttribute("targetLang") if translation.hasAttribute("targetLang") else ""
|
||||||
|
else:
|
||||||
|
self.translation = ""
|
||||||
|
self.source = ""
|
||||||
|
self.targetLang = ""
|
||||||
|
|
||||||
explanation = translation_xml.querySelector("explanation")
|
explanation = translation_xml.querySelector("explanation")
|
||||||
self.explanation = explanation.textContent if explanation else ""
|
self.explanation = explanation.textContent if explanation else ""
|
||||||
|
self.tags = import_label_list("labelList label", translation_xml)
|
||||||
self.tags = []
|
|
||||||
for tag_xml in translation_xml.querySelectorAll("labelList label"):
|
|
||||||
t_type = tag_xml.getAttribute("type")
|
|
||||||
t_value = tag_xml.textContent
|
|
||||||
|
|
||||||
if t_type not in TAGS:
|
|
||||||
console.log("Bad tag: ({})->({})".format(t_type, t_value))
|
|
||||||
continue
|
|
||||||
|
|
||||||
self.tags.append((t_type, t_value))
|
|
||||||
|
|
||||||
|
Loading…
Reference in new issue