Skip to content

Commit 38fe0c2

Browse files
Fixed script adding single quotes instead of double quotes
1 parent 6b314f4 commit 38fe0c2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

AndroidResourceTranslator.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,18 @@ def update_xml_file(resource: AndroidResourceFile) -> None:
258258

259259
try:
260260
tree.write(resource.path, encoding="utf-8", xml_declaration=True)
261+
# Post-process the file to replace single quotes with double quotes in the XML declaration.
262+
with open(resource.path, "r+", encoding="utf-8") as f:
263+
content = f.read()
264+
# Replace the XML declaration that uses single quotes with one using double quotes.
265+
content = re.sub(
266+
r'^<\?xml version=\'1\.0\' encoding=\'utf-8\'\?>',
267+
'<?xml version="1.0" encoding="utf-8"?>',
268+
content
269+
)
270+
f.seek(0)
271+
f.write(content)
272+
f.truncate()
261273
logger.info(f"Updated XML file: {resource.path}")
262274
except Exception as e:
263275
logger.error(f"Error writing XML file {resource.path}: {e}")

0 commit comments

Comments
 (0)