Created
June 10, 2015 07:17
-
-
Save clarkli86/53ee0abfa7211caeec0e to your computer and use it in GitHub Desktop.
Convert Android strings.xml into iOS Localizable.strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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