-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfix lang.py
More file actions
26 lines (21 loc) · 879 Bytes
/
fix lang.py
File metadata and controls
26 lines (21 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/python
import os
import xml.etree.ElementTree as ET
from xml.dom import minidom
res_path: str = "composeApp/src/androidMain/res"
def fix_quot_and_header():
for root, dirs, files in os.walk(res_path):
if "values" in os.path.basename(root):
file_path = os.path.join(root, "strings.xml")
if os.path.exists(file_path):
tree = ET.parse(file_path)
root_elem = tree.getroot()
for string in root_elem.findall("string"):
if string.text:
string.text = string.text.replace('"', '"')
string.tail = '\n'
root_elem.text = '\n'
tree.write(file_path, encoding="utf-8", xml_declaration=True)
print(f"File fixed : {file_path}")
if __name__ == '__main__':
fix_quot_and_header()