import os import sys def alignpos(f, align): cur = f.tell() if cur % align != 0: f.seek((align - cur % align) + cur) def readstr(f): strbytes = bytearray() strln = int.from_bytes(f.read(4), byteorder='little') for i in range(strln): strbytes.append(ord(f.read(1))) return str(strbytes, 'utf-8') def read(file, lc='en'): result = '' with open(file, 'rb') as f: f.seek(-12, os.SEEK_END) loc = readstr(f) if loc != lc: return print('Locale: %s' % loc) f.seek(0x1C) filename = readstr(f) alignpos(f, 4) count = int.from_bytes(f.read(4), byteorder='little') print('File: %s\nCount: %i\n' % (filename, count)) f.read(12) for i in range(count): mesid = readstr(f) alignpos(f, 4) messtr = readstr(f) alignpos(f, 4) f.read(0x10) result += messtr + '\n' with open(filename + '.txt', 'w', encoding='utf-8') as r: r.write(result) # en - english, ru - russian read(sys.argv[1], 'en')