INNER CODE UNIT · Python
xml_to_dict
futo-org/android-keyboard · tools/make-keyboard-text-py/src/migrate.py:12
def xml_to_dict(xml_file):
tree = ET.parse(xml_file)
root = tree.getroot()
locale_data = {prefix.rstrip('_'): {} for prefix in prefixes}
locale_data['other'] = {}
for string in root.findall('string'):
name = string.get('name')
value = string.text or ""
value = value.replace("\\\\", "\\")
if value.startswith('"') and value.endswith('"'):
value = value.lstrip('"').rstrip('"')
# Categorize based on prefixes
categorized = False
for prefix in prefixes: