Skip to content

Instantly share code, notes, and snippets.

@clarkli86
Created June 10, 2015 07:17
Show Gist options
  • Select an option

  • Save clarkli86/53ee0abfa7211caeec0e to your computer and use it in GitHub Desktop.

Select an option

Save clarkli86/53ee0abfa7211caeec0e to your computer and use it in GitHub Desktop.
Convert Android strings.xml into iOS Localizable.strings
#!/usr/bin/python
import xml.etree.ElementTree as ET
import sys, getopt
def read_from_xml(infile):
tree = ET.parse(infile)
root = tree.getroot()
pairs = []
for string in root:
pairs.append((string.attrib['name'], string.text))
return pairs
def write_to_ini(pairs):
for pair in pairs:
# Print to stdout
print '"' + pair[0] + '" = "' + pair[1] + '";'
if __name__ == "__main__":
write_to_ini(read_from_xml(open(sys.argv[1])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment