import json import codecs import struct def json_to_lang(filename_json, filename_lang): with codecs.open(filename_json, 'r', 'utf-8') as f: strings = json.load(f) with open(filename_lang, 'wb') as f: for s in strings: if s['definition'] is None: continue term = s['term'].encode('utf-8') f.write(struct.pack(' os.path.getmtime(filename_lang): print('Building language file: {:s} => {:s}'.format(os.path.basename(filename_json), os.path.basename(filename_lang))) json_to_lang(filename_json, filename_lang)