Skip to content

Instantly share code, notes, and snippets.

@irace
Created August 15, 2012 20:54
Show Gist options
  • Save irace/3363569 to your computer and use it in GitHub Desktop.
Save irace/3363569 to your computer and use it in GitHub Desktop.
Generate iOS Localizable.strings format from PO file
#!/usr/bin/python
import sys
if __name__ == '__main__':
filename = sys.argv[1];
input = open(filename)
output = open(filename + '.out', 'w')
for line in input:
if line.startswith('#. '):
output.write(line.replace('#. ', ''))
elif line.startswith('#: '):
output.write(line.replace('#: ', '"').replace('\n', '" = '))
elif line.startswith('msgstr '):
output.write(line.replace('msgstr ', '').replace('\n', ';\n\n'))
input.close()
output.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment