You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.0 KiB
26 lines
1.0 KiB
from model.tags import TAGS
|
|
from model.editable import Editable
|
|
|
|
|
|
class Translation(Editable):
|
|
def __init__(self, translation_xml):
|
|
translation = translation_xml.querySelector("translation")
|
|
self.translation = translation.textContent
|
|
self.source = translation.getAttribute("source") if translation.hasAttribute("source") else ""
|
|
self.targetLang = translation.getAttribute("targetLang") if translation.hasAttribute("targetLang") else ""
|
|
|
|
explanation = translation_xml.querySelector("explanation")
|
|
self.explanation = explanation.textContent if explanation else ""
|
|
|
|
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))
|
|
|