Dies Irae - make import script from python export script

How to translate the files of a game
masagrator
Posts: 82
Joined: Sat Dec 22, 2018 10:03 am

Dies Irae - make import script from python export script

Post by masagrator »

Hello. I got working export script for game Dies Irae from github Inori/*SPAM*
Someone could help to make it importing text? This script can bring english translation for Dies Irae to Switch and Android version.

Code: Select all

# -*- coding:utf-8 -*-

import struct,os,fnmatch,re,tempfile

def byte2int(byte):
    long_tuple=struct.unpack('L',byte)
    long = long_tuple[0]
    return long

def int2byte(num):
    return struct.pack('L',num)

def FormatString(string, count):
    res = "Line%08d\n%s\n"%(count, string+'\n')
   
    return res

def GetEntry(src):
    start = 0x338CED
    src.seek(start)
    end = 0x389250 -4
    count = (end-start)//8

    entry_list = []
    for i in range(0, count):
        offset = byte2int(src.read(4))
        length = byte2int(src.read(4))
        entry_list.append([offset, length])
    return entry_list

src = open('exec.dat', 'rb')
dst = open('switch.dat.txt', 'w', encoding='utf16')
entry = GetEntry(src)

j = 0
for [offset, length] in entry:
    src.seek(offset + 0x389250)
    bstring = src.read(length)
    string = bstring.decode('sjis', errors='ignore')
    dst.write(FormatString(string,j))
    #dst.write(string[:-2]+'\n')
    j += 1

src.close()
dst.close()   


And in exec.zip from attachment is exec.dat.
masagrator
Posts: 82
Joined: Sat Dec 22, 2018 10:03 am

Re: Dies Irae - make import script from python export script

Post by masagrator »

I made cleaner export script for people who got afraid of dictionary.