- index = 0
- line_nbr = 0
- for f in found:
- group = 1 if f.group(1) else 2
- while index < f.start():
- if content[index] == "\n":
- line_nbr += 1
- index += 1
- result.append((line_nbr, None, f.group(group), ""))
+ def handle_text(str):
+ str = (str or "").strip()
+ if not str:
+ return
+ result.append((0, None, str, ""))
+
+ def iter_elements(current_element):
+ for el in current_element:
+ if "t-js" not in el.attrib and \
+ not ("t-jquery" in el.attrib and "t-operation" not in el.attrib) and \
+ not ("t-translation" in el.attrib and el.attrib["t-translation"].strip() == "off"):
+ handle_text(el.text)
+ iter_elements(el)
+ handle_text(el.tail)
+
+ tree = elt.parse(fileobj)
+ iter_elements(tree.getroot())
+