|
|
@ -10,7 +10,8 @@ TAGS = {
|
|
|
|
"semantično": [],
|
|
|
|
"semantično": [],
|
|
|
|
"kontekstualna": [],
|
|
|
|
"kontekstualna": [],
|
|
|
|
"Polno angleško": [],
|
|
|
|
"Polno angleško": [],
|
|
|
|
"Blagovna znamka": []
|
|
|
|
"Blagovna znamka": [],
|
|
|
|
|
|
|
|
"SKRIJ POMEN": ["Skrij"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SLO2ENG_TAGS = {
|
|
|
|
SLO2ENG_TAGS = {
|
|
|
@ -26,7 +27,8 @@ SLO2ENG_TAGS = {
|
|
|
|
"semantično": "semantic",
|
|
|
|
"semantično": "semantic",
|
|
|
|
"kontekstualna": "context",
|
|
|
|
"kontekstualna": "context",
|
|
|
|
"Polno angleško": "English-full",
|
|
|
|
"Polno angleško": "English-full",
|
|
|
|
"Blagovna znamka": "trademark"
|
|
|
|
"Blagovna znamka": "trademark",
|
|
|
|
|
|
|
|
"SKRIJ POMEN": "hide-sense",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ENG2SLO_TAGS = { value: key for key, value in SLO2ENG_TAGS.items() }
|
|
|
|
ENG2SLO_TAGS = { value: key for key, value in SLO2ENG_TAGS.items() }
|
|
|
@ -42,7 +44,7 @@ def import_label_list(selector, xml_element):
|
|
|
|
for tag_xml in xml_element.querySelectorAll(selector):
|
|
|
|
for tag_xml in xml_element.querySelectorAll(selector):
|
|
|
|
t_type = tag_xml.getAttribute("type")
|
|
|
|
t_type = tag_xml.getAttribute("type")
|
|
|
|
t_value = tag_xml.textContent
|
|
|
|
t_value = tag_xml.textContent
|
|
|
|
|
|
|
|
|
|
|
|
t_type, t_value = import_tag(t_type, t_value)
|
|
|
|
t_type, t_value = import_tag(t_type, t_value)
|
|
|
|
result.append((t_type, t_value))
|
|
|
|
result.append((t_type, t_value))
|
|
|
|
return result
|
|
|
|
return result
|
|
|
@ -54,14 +56,14 @@ def import_tag(key, value):
|
|
|
|
# simmilar for "stilne"
|
|
|
|
# simmilar for "stilne"
|
|
|
|
# if english, than translate and change style-xxx for stilne
|
|
|
|
# if english, than translate and change style-xxx for stilne
|
|
|
|
# for value, just handle if some bad "-- xxx" stuff is in xml
|
|
|
|
# for value, just handle if some bad "-- xxx" stuff is in xml
|
|
|
|
|
|
|
|
|
|
|
|
if key in SLO2ENG_TAGS:
|
|
|
|
if key in SLO2ENG_TAGS:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
elif key in ("stilne", "style"):
|
|
|
|
elif key in ("stilne", "style"):
|
|
|
|
key = "stilne"
|
|
|
|
key = "stilne"
|
|
|
|
elif key in ENG2SLO_TAGS:
|
|
|
|
elif key in ENG2SLO_TAGS:
|
|
|
|
key = ENG2SLO_TAGS[key]
|
|
|
|
key = ENG2SLO_TAGS[key]
|
|
|
|
|
|
|
|
|
|
|
|
# handle stilne-xxx stuff
|
|
|
|
# handle stilne-xxx stuff
|
|
|
|
if "-" in key:
|
|
|
|
if "-" in key:
|
|
|
|
key = key.split("-")[0]
|
|
|
|
key = key.split("-")[0]
|
|
|
@ -69,15 +71,18 @@ def import_tag(key, value):
|
|
|
|
window.console.log("Uknown tag :(", key, value)
|
|
|
|
window.console.log("Uknown tag :(", key, value)
|
|
|
|
# using some default
|
|
|
|
# using some default
|
|
|
|
key = TAGS.keys()[0]
|
|
|
|
key = TAGS.keys()[0]
|
|
|
|
|
|
|
|
|
|
|
|
# this should not happen, but maybe there was a bug...
|
|
|
|
# this should not happen, but maybe there was a bug...
|
|
|
|
value = value.replace("--", "").strip()
|
|
|
|
value = value.replace("--", "").strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if key == "SKRIJ POMEN" and value == "true":
|
|
|
|
|
|
|
|
value = "Skrij"
|
|
|
|
|
|
|
|
|
|
|
|
for tag_key in TAGS.keys():
|
|
|
|
for tag_key in TAGS.keys():
|
|
|
|
for possible_value in TAGS[tag_key]:
|
|
|
|
for possible_value in TAGS[tag_key]:
|
|
|
|
if value == possible_value or "-- " + value == possible_value:
|
|
|
|
if value == possible_value or "-- " + value == possible_value:
|
|
|
|
return key, possible_value
|
|
|
|
return key, possible_value
|
|
|
|
|
|
|
|
|
|
|
|
# not found, must be manually inputted
|
|
|
|
# not found, must be manually inputted
|
|
|
|
return key, value
|
|
|
|
return key, value
|
|
|
|
|
|
|
|
|
|
|
@ -87,18 +92,19 @@ def export_tag(key, value):
|
|
|
|
arr = TAGS["stilne"]
|
|
|
|
arr = TAGS["stilne"]
|
|
|
|
key = "style"
|
|
|
|
key = "style"
|
|
|
|
value_idx = arr.index(value)
|
|
|
|
value_idx = arr.index(value)
|
|
|
|
|
|
|
|
|
|
|
|
if value_idx >= 0:
|
|
|
|
if value_idx >= 0:
|
|
|
|
for sec_slo, sec_eng in reversed(STYLE_SECTIONS):
|
|
|
|
for sec_slo, sec_eng in reversed(STYLE_SECTIONS):
|
|
|
|
idx = arr.index(sec_slo)
|
|
|
|
idx = arr.index(sec_slo)
|
|
|
|
if idx < value_idx:
|
|
|
|
if idx < value_idx:
|
|
|
|
key = "style-" + sec_eng
|
|
|
|
key = "style-" + sec_eng
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
key = SLO2ENG_TAGS[key]
|
|
|
|
key = SLO2ENG_TAGS[key]
|
|
|
|
|
|
|
|
if key == "hide-sense":
|
|
|
|
|
|
|
|
value = "true"
|
|
|
|
value = value.replace("--", "").strip()
|
|
|
|
value = value.replace("--", "").strip()
|
|
|
|
return key, value
|
|
|
|
return key, value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|