Spotter-VM/extra/frontlinesms-lang-js.py

16 lines
551 B
Python
Raw Normal View History

#!/usr/bin/env python3
import gzip
import json
d = {}
with open('messages_cs.txt', 'r') as input, open('messages_cs.properties', 'w') as output:
for line in input.read().splitlines():
print(json.dumps(line)[1:-1], end='\n', file=output)
if line and not line.startswith('#'):
key,value = line.split('=', 1)
d[key] = value
with open('frontlinesms-core_messages_cs.js', 'wb') as f:
f.write('var i18nStrings = i18nStrings || {{}}; i18nStrings["frontlinesms-core"] = {};'.format(json.dumps(d)).encode())