LeOS-Ice-browser/check_i18n_strings.py

23 lines
585 B
Python
Raw Normal View History

2024-08-26 10:00:43 +02:00
import glob
import xml.etree.ElementTree as ET
from collections import defaultdict
def check_xml(file_path):
tree = ET.parse(file_path)
root = tree.getroot()
name_cache = defaultdict(int)
for elem in root:
name = elem.attrib.get('name')
if name:
name_cache[name] += 1
for name, count in name_cache.items():
if count > 1:
print(f"{file_path}: {name} - {count} occurrences")
search_path = 'app/src/main/res/**/values-*/strings.xml'
for file_path in glob.glob(search_path, recursive=True):
check_xml(file_path)